This is a Spring Boot 3.5.5 demo project using:
- Spring Data JPA (with Microsoft SQL Server)
- Spring Web
- Spring Boot Validation
- MapStruct for DTO mapping
- Lombok for boilerplate reduction
- (Optional) Spring Security + OAuth2 Resource Server (JWT)
The project demonstrates:
- A base
BaseEntitywith audit fields (createdAt,updatedAt,userId) - A sample
Employeeentity with CRUD capabilities - Pre-configured Hibernate and logging
- A ready-to-enable
SecurityConfigfor OAuth2 JWT-based security
src/main/java/com/example/demo/
├── core/
│ ├── config/
│ │ └── SecurityConfig.java # 🔒 Security setup (commented until enabled)
│ └── contract/
│ └── BaseEntity.java # Common audit fields
├── employee/
│ └── dao/
│ └── entity/
│ └── Employee.java # Example entity
└── DemoApplication.java # Main Spring Boot class
- Java 17+
- Maven 3.8+
- Docker (if running SQL Server in a container)
docker network create db
docker run -itd --rm --network db \
-e "ACCEPT_EULA=Y" \
-e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" \
-p 1433:1433 \
--name mssql \
--mount type=bind,source=/your/local/path/mssql,target=/var/opt/mssql/data \
mcr.microsoft.com/mssql/server:2022-latestThe default configuration is in src/main/resources/application.yml:
spring:
datasource:
url: jdbc:sqlserver://localhost:1433;databaseName=demo;encrypt=false
username: sa
password: YourStrong!Passw0rd
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
jpa:
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate.format_sql: true
hibernate.transaction.jta.platform: org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
hibernate.dialect: org.hibernate.dialect.SQLServerDialectmvn spring-boot:runVisit:
http://localhost:8080/actuator/health→ to verify app is up.- (Add controllers to expose your REST APIs)
- Go to
core/config/SecurityConfig.java - Uncomment
@Configurationand@EnableWebSecurity - Update
application.ymlwith your JWT issuer or public key
spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: https://your-auth-server/.well-known/openid-configurationRestart the app and your endpoints will require JWT tokens.
mvn clean packageThe JAR will be available at target/demo-0.0.1-SNAPSHOT.jar:
java -jar target/demo-0.0.1-SNAPSHOT.jar| Command | Description |
|---|---|
mvn spring-boot:run |
Run the app in dev mode |
mvn clean package |
Build executable JAR |
docker ps |
Check if SQL Server container is running |
docker logs mssql |
View SQL Server logs |
- Setup Spring Boot project with JPA + SQL Server
- Add BaseEntity with audit fields
- Configure Hibernate + logging
- Prepare SecurityConfig (disabled by default)
- Add sample REST Controllers
- Enable OAuth2 security with JWT
- Add integration tests
This project is licensed under the MIT License — you are free to use, modify, and distribute.
Feel free to open issues or submit PRs to improve this demo project.
#springboot #jpa #sqlserver #mapstruct #lombok #oauth2 #jwt #demo #java #maven