SpringBootScaffold
is a scaffold for Spring Boot project. It contains basic configurations and common used components.
- Spring Boot:
3.1.0
- Spring JPA
- Spring Web
- Thymeleaf
- Validation
- Spring Test
- Database Connector:
- H2 Database:
2.2.224
- MySQL Connector:
8.2.0
- PostgreSQL:
42.7.1
- H2 Database:
- Spring Doc (Swagger):
2.3.0
- Lombok:
1.18.30
- Mapstruct:
1.5.5.Final
Click to expand
- Make sure your IDEA IDE setting to JDK 17.
- Run
MainApplication.java
to start the server. - Open http://localhost:8080/swagger-ui/index.html to see the swagger doc.
- The data will save to H2 database file
./springboot_scaffold.mv.db
by default.
Click to expand
SpringBootScaffold uses H2
memory database default. It can be changed easily to other database by specifying environment variables or application.yml
.
Following shows how to change by environment variables.
H2 is DEFAULT database for SpringBootScaffold. Its configuration is:
DB_JDBC_URL=jdbc:h2:mem:springboot_scaffold
DB_USERNAME=sa
DB_PASSWORD=password
DB_DRIVER_CLASS=org.h2.Driver
DB_JPA_DIALECT=org.hibernate.dialect.H2Dialect
Once Spring Boot started, H2 can be access by http://localhost:8080/h2-console.
Create a MySQL database named springboot_scaffold
, then setup environment variables as following (change accordingly):
DB_JDBC_URL=jdbc:mysql://localhost:3306/springboot_scaffold?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=GMT%2B8
DB_USERNAME=root
DB_PASSWORD=12345678
DB_DRIVER_CLASS=com.mysql.cj.jdbc.Driver
DB_JPA_DIALECT=org.hibernate.dialect.MySQLDialect
Create a PostgreSQL database named springboot_scaffold
, then setup environment variables as following (change accordingly):
DB_JDBC_URL=jdbc:postgresql://localhost:5432/springboot_scaffold
DB_USERNAME=postgres
DB_PASSWORD=12345678
DB_DRIVER_CLASS=org.postgresql.Driver
DB_JPA_DIALECT=org.hibernate.dialect.PostgreSQLDialect
Click to expand
java --version # make sure your java version is 17
./gradlew clean build
java -jar build/libs/SpringbootScaffold.jar