This Spring Boot application demonstrates a simple hotel booking system with CRUD functionality, utilizing an H2 in-memory database for data persistence. This README provides instructions on setting up and running the application, as well as connecting to the H2 database console for data verification and testing.
These instructions will guide you through setting up and running the application on your local machine.
Ensure you have the following installed:
- JDK 17 or newer
- Maven
- An IDE (e.g., IntelliJ IDEA, VS Code)
-
Clone the repository
Open your terminal and run:
git clone https://gitlab.com/ranitraj/Spring-HotelManagementSystem.git cd Spring-HotelManagementSystem
-
Build the project
Using Maven:
mvn clean install
-
Run the application
Execute the following command:
mvn spring-boot:run
The application will start and be accessible at
http://localhost:8080
.
The H2 database console is enabled by default and can be accessed through your web browser for direct database interactions:
- Navigate to
http://localhost:8080/h2-console
in your browser. - Use the following settings to connect:
- JDBC URL:
jdbc:h2:mem:booking_db
- User Name:
sa
- Password: (leave this blank)
- JDBC URL:
- Click Connect to access the database console.
You can test the API endpoints using Postman or any other API testing tool by sending requests to http://localhost:8080/bookings
. Below are sample requests for each available endpoint.
-
Method: POST
-
URL:
/bookings
-
Body:
{ "customerName": "John Doe", "roomType": "Deluxe", "checkInDate": "2024-02-08 00:00:00", "checkOutDate": "2024-02-10 00:00:00", "totalPrice": 250.0 }
- Method: GET
- URL:
/bookings
- Method: GET
- URL:
/bookings/{id}
-
Method: PUT
-
URL:
/bookings/{id}
-
Body: (Modify as needed)
{ "customerName": "Jane Doe Updated", "roomType": "Suite", "checkInDate": "2024-02-09 00:00:00", "checkOutDate": "2024-02-11 00:00:00", "totalPrice": 300.0 }
- Spring Boot - The web framework used
- H2 Database - In-memory database for development and testing
- Maven - Dependency Management