- RESTful API Server Sample code based on Spring boot
- Major Exceptions are managed by RestControllerAdvice and ExceptionHandler
- Database such as H2DB is accessed such as insert, select, update and delete (CRUD) via Spring Data JPA
- It controls race condition using LockModeType.PESSIMISTIC_WRITE provided JPA
- API Documentation using Springdoc-openapi
- Code simplification using Lombok
- Container creation and execution using Docker
- Logging using Aspect and @Around
- Add security configuration using Spring Security such as basic authentication
- Add link to response using HATEOAS
- Add Server-Sent Event (SSE) example for real-time notification
- JDK 21
- spring-boot 3.3.5
- spring-boot-web
- spring-boot-data-jpa
- spring-boot-security
- spring-boot-cache
- ehcache / hazelcast
- springdoc-openapi
- h2database
- lombok
- spring-boot-hateoas
- GET /api/v1/announcements
- GET /api/v1/announcements/page
- GET /api/v1/announcement/id/{id}
- POST /api/v1/announcement
- POST /api/v1/announcement/id/{id}
- PUT /api/v1/announcement/id/{id}
- DELETE /api/v1/announcement/id/{id}
- DELETE /api/v1/announcement/id/{id}/file-id/{fileId}
docker build -t demo-api:local . && docker run -p 9090:8080 -e"SPRING_PROFILES_ACTIVE=local" demo-api:local
docker build -t demo-api:local -f Dockerfile_git . && docker run -p 9090:8080 -e"SPRING_PROFILES_ACTIVE=local" demo-api:local
docker build -t demo-api:local -f Dockerfile_aot . && docker run -p 9090:8080 -e"SPRING_PROFILES_ACTIVE=local" demo-api:local
docker build -t demo-api:local -f Dockerfile_cds . && docker run -p 9090:8080 -e"SPRING_PROFILES_ACTIVE=local" demo-api:local
docker-compose up
- Race condition problem of database access
- Apply to restrict access to other sessions during change through lock such as LockModeType.PESSIMISTIC_WRITE (for update) in DB table row
- Lack of memory problem by increasing platform threads
- In order to reduce memory usage per request, using virutal thread
- Parallel processing through jdk.virtualThreadScheduler.parallelism setting, default value is number of cpu core
- Security Problem
- Apply universal security configuration to handle spring security
- Only authenticated users can access the API through basic authentication or OAuth Token
- Problem of frequently access database for authentication in short time
- Apply local cache through Ehcache
- Apply cache data sharing through Hazelcast clustering
- Instance startup time and library loading issues
- Minimize instance startup time through image creation through Graalvm AOT compilation
- account
- robot / play
- sam / ground
- method
- swagger-ui.html
- Ehcache can be compiled to native image by GraalVM in order for local caching and executed properly
- It is hard to compile Hazelcast native image via GraalVM, and Hazelcast might not be supported officially
- SpringBoot cache with Hazelcast 5.2.4 is compiled by GraalVM native image and executed properly, however, another Hazelcast versions such as over 5.2.4 can be compiled but occurred runtime error.
- When application is started, Hazelcast needs to get cluster information and make a clustering. so it has needed to time to complete Clustering and synchronizing cache data.
- GraalVM 21.0.2
- The size of native image is about 66.9MB
- The startup time of native image is about 1.351s
- GraalVM 23
- https://medium.com/graalvm/welcome-graalvm-for-jdk-23-203928491b2b
- oracle/graal#7626
The size of native image is about 66.9MBThe startup time of native image is about 1.351s