Spring Boot + Java [ DDD Sample ]
It is DDD sample implementation from Spring Boot.
It is not a framework, This is a simple example of the implementation based on Evans’s DDD.
It is three levels of famous models, but considers the infrastructure layer as cross-sectional interpretation.
Layer | |
---|---|
UI | Receive use case request |
Application | Use case processing (including the outside resource access) |
Domain | Pure domain logic (not depend on the outside resource) |
Infrastructure | DI container and ORM, various libraries |
Usually perform public handling of UI layer using Thymeleaf, but this sample assume use of different types of clients and perform only API offer in RESTfulAPI.
Spring Boot is available for various usage, but uses it in the following policy with this sample.
Refer to the following for the package / resource constitution.
main
java
sample
context … Infrastructure Layer
controller … UI Layer
model … Domain Layer
usecase … Application Layer
util … Utilities
- Application.java … Bootstrap
resources
- application.yml … Spring Boot Configuration
- messages-validation.properties … Validation Message Resources
- messages.properties … Label Message Resources
Consider the following as a sample use case.
This sample uses Gradle, you can check the operation without trouble with IDE and a console.
It is necessary to do the following step.
Do the preparations for this sample in the next step.
code .
.Do the server start in the next step.
Run ddd-java
.curl http://localhost:8080/actuator/health
Run application from a console of Windows / Mac in Gradle.
It is necessary to do the following step.
Do the server start in the next step.
./gradlew bootRun --args='--spring.profiles.active=dev'
.curl http://localhost:8080/actuator/health
After launching the server on port 8080, you can test execution of RESTful API by accessing the following URL from console.
curl -X POST -H "Content-Type: application/json" -d '{"accountId" : "sample" , "currency" : "JPY", "absAmount": 1000}' http://localhost:8080/asset/cio/withdraw
curl 'http://localhost:8080/asset/cio/unprocessedOut'
curl 'http://localhost:8080/admin/asset/cio?updFromDay=yyyy-MM-dd&updToDay=yyyy-MM-dd'
curl -X POST http://localhost:8080/system/job/daily/closingCashOut
curl -X POST http://localhost:8080/system/job/daily/processDay
curl -X POST http://localhost:8080/system/job/daily/realizeCashflow
Please execute according to the business day appropriately
The license of this sample includes a code and is all MIT License.
Use it as a base implementation at the time of the project start using Spring Boot.