A modern boilerplate or project structure for Springboot API with common toolkit π
.
βββ bin/
βββ docker/
βββ scripts/
βββ src
βββ main
βββ java/
βββ com.kelvn/
βββ config/
βββ controller/
βββ dto/
βββ enums/
βββ exception/
βββ model/
βββ repository/
βββ security/
βββ service/
βββ utils/
βββ resources/
βββ target/
βββ .gitignore
βββ pom.xml
βββ README.md
-
Warning Version:
11
-
Generating Qmodel (QueryDsl)
mvn clean install
Note: Model classes will be generated into folder target/generated-sources/**/model, copy it to src for using purpose
-
Generating cryptographic keys
Warning: The openssl extension is required
openssl version
-
To generates a new RSA private key with a length of 2048 bits
openssl genrsa -out keypair.pem 2048
-
To extracts the public key
openssl rsa -in keypair.pem -pubout -out public.pem
-
To converts the private key into the PKCS#8 format
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out private.pem
Note: Or simply
sh bin/setup-jwt-key.sh
-
-
π Formatting
-
To implement automated code formatting
mvn spotless:apply
-
To validate if code was formatted
mvn spotless:check
-
-
Githooks
-
To setup pre-commit
cp scripts/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
Note: Or simply
sh bin/setup-pre-commit.sh
Note: To not run pre-commit
git commit -m "${message}" --no-verify
-
-
Deployment
sh bin/build-and-push-image.sh -e ${env}
Note: Bonus
-
To build project
mvn clean install -DskipTests -P ${env}
-
To execute .jar file
java -jar ${filename}.jar
-
- Visit here to learn more about Best Practices in Spring Boot Project Structure
- Visit here to learn more about πDependency Injection
- Visit here to learn more about Base Entity or AbstractPersistable for alternatives
- Visit here to learn more about Database Audit
- Visit here to learn more about Soft Delete functionality
- Visit here to learn more about production-grade dynamic filters using QueryDSL
- Visit here to learn more about Spring Security + JWTs
- Visit here to learn more about Log request and responses of REST APIs
- Visit here to learn more about Spring Boot REST API Error Handling
- Visit here to learn more about ModelMapper with more complex objects
- Visit here to learn more about Spotless formatting with Git pre-commit hook
- Visit here to learn more about RabbitMQ
- Visit Google, Spring blog to learn more about OAuth 2.0 for Client-side and OAuth 2.0 Playground, Graph API Explorer for testing purpose
- Visit Official Docs, JPA Buddy to learn more about Dynamic Entity Graph
(C)2023