This is a simple Spring Boot application designed to demonstrate the core functionality of a Spring Boot project. It includes basic setup, controller mapping, and database integration.
- Features
- Technologies Used
- Setup Instructions
- Build and Run the Project
- Endpoints
- Troubleshooting
- Contributing
- License
- RESTful API endpoints with Spring Boot
- Integration with a relational database (e.g., MySQL, PostgreSQL, or H2)
- Support for embedded server (Tomcat)
- Custom error handling and whitelabel error page replacement
- Spring Boot 3.x
- Java 17+
- Maven for dependency management
- Database: MySQL/PostgreSQL or H2 (embedded)
- Spring Data JPA for database operations
Follow these steps to run the project locally:
- Prerequisites
- Java 17 or higher installed
- Maven installed
- Database server (e.g., MySQL/PostgreSQL) running
- Clone the Repository
git clone https://github.com/your-username/demo-project.git
cd demo-project
- Configure the Application
- Update the application.properties file located in src/main/resources:
# Server port
server.port=8080
# Database configuration
spring.datasource.url=jdbc:mysql://localhost:3306/databasename
spring.datasource.username=your-username
spring.datasource.password=your-password
spring.jpa.hibernate.ddl-auto=update
- Create a database named demo in your MySQL/PostgreSQL server:
CREATE DATABASE databasename;
- Clean and build the project:
mvn clean install
- Run the project:
mvn spring-boot:run
- Open your browser and visit:
http://localhost:8080
Method | Endpoint | Description |
---|---|---|
GET | / |
Displays a welcome message. |
GET | /error |
Custom error page. |
GET | /api/resource |
Example REST API endpoint. |
-
Whitelabel error page (404) -Ensure a controller is mapped to / or static resources are present in the src/main/resources/static folder.
-
Database Connection issues -Verify the database credentials in application.properties. -Ensure the database server is running.
-
Port Already in Use -Change the port in application.properties
server.port=8081
- Logs for more information -Run with debug mode enabled:
mvn spring-boot:run -Dspring-boot.run.arguments=--debug
Contributions are welcome! Feel free to open issues or submit pull requests to improve this project.
This project is licensed under the MIT License. See the LICENSE file for more details.