Table of Contents
This is a template for a REST API using Spring Boot. It was created to be used as a base for future projects.
- REST API
- Domain-Driven Design
- Tests with JUnit Jupiter, MockMvc and Mockito
- Databases with H2 embedded database
- Custom Exception Handling
- Swagger UI API
-
. Clone the repo
Fork or clone the repo: https://github.com/hoaflee/lnp-chatgpt.git
-
Run using Maven or your IDE
mvn spring-boot:run
-
In order to run the tests
mvn test
-
Some relevant lines from the application.properties
# localhost:8080/ port=8080 # localhost:8080/swagger-ui/index.html springdoc.swagger-ui.path=/swagger-ui.html springdoc.api-docs.path=/v3/api-docs sprindoc.swagger-ui.config-url=/v3/api-docs/swagger-config springdoc.swagger-ui.url=/v3/api-docs # H2 Database name - in memory database spring.datasource.url=jdbc:h2:mem:testdb spring.h2.console.enabled=true # localhost:8080/h2-console spring.h2.console.path=/h2-console spring.datasource.driverClassName=org.h2.Driver # authentication to access the database console spring.datasource.username=sa spring.datasource.password=
-
An API documentation can be accessed through localhost:8080/swagger-ui/index.html once the program is running
- Create a basic REST API
- Add a database support
- Add a Swagger UI API documentation
- Add tests for the controllers, services and repositories
- Add a security layer
- Add remote database support
- Add a Dockerfile for the application
- And more...?