A template for Spring Boot projects. This template includes the following features:
- Spring Boot 3.0.6
- Spring Security with JWT authentication and authorization also with refresh token
- Swagger UI for API documentation and testing (http://localhost:8080/api/v1/swagger-ui/index.html) with authentication and authorization support
- Spring Data JPA with PostgreSQL database integration
- Exception handling mechanism with custom exceptions and exception handlers using
@ControllerAdvice
- Base entity and base DTO for common fields
- Base service for common business logic
- Custom
@PreAuthorize
annotation for authorization - Lombok for reducing boilerplate code
- MapStruct for mapping DTOs to entities and vice versa
- Clone this repository
- Create a PostgreSQL database
- Change the database configuration in
application.properties
- Run the application with
mvn spring-boot:run
- Open http://localhost:8080/api/v1/swagger-ui/index.html in your browser
- Register a new user
- Login with the registered user
- Copy the JWT token from the response
- Click the
Authorize
button in the Swagger UI - Paste the JWT token in the
Value
field without theBearer
prefix - Click the
Authorize
button - Now you can test the API endpoints
- To test the refresh token endpoint, click the
Authorize
button again and paste the refresh token in theValue
field without theBearer
prefix
If you want to contribute to this project, please create a pull request.