https://github.com/lucasdengcn/spring-native-image-starter
Practices on Spring Native Image and Spring boot, for adopting GraalVM on cloud native
https://github.com/lucasdengcn/spring-native-image-starter
spring-boot-3 spring-native
Last synced: 2 months ago
JSON representation
Practices on Spring Native Image and Spring boot, for adopting GraalVM on cloud native
- Host: GitHub
- URL: https://github.com/lucasdengcn/spring-native-image-starter
- Owner: lucasdengcn
- Created: 2024-08-21T04:39:37.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-19T06:37:44.000Z (over 1 year ago)
- Last Synced: 2025-01-01T09:10:47.870Z (over 1 year ago)
- Topics: spring-boot-3, spring-native
- Language: Kotlin
- Homepage:
- Size: 75.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Native Image Demo
## Tech Stack
- JDK 21
- Graalvm-jdk-21.0.5+9.1
- Kotlin 1.9.x
- Spring Boot 3.3.x
- Spring Cloud 2023.0.3
- Resilience4j
- Hibernate
- Spring Data JPA
- MapStruct
- Undertow
- OpenFeign
- CloudEvents
- Open API Specification
- PostgreSQL
- JUnit 5
- DataFaker
- Kafka
- Redis
- Gradle
- Kapt
- Gradle Native Build tools
- RFC-9457
## Capabilities to Verify
| Component | Able To Run? |
|----------------|--------------|
| JPA | Yes |
| Controllers | Yes |
| Flyway | No |
| OpenFeign | Yes |
| Redis Client | Yes |
| Kafka Client | Yes |
| Resilience4j | Yes |
| Map Struct | Yes |
| Swagger UI | Yes |
| Validation | Yes |
| Cacheable | Yes |
| Kafka Listener | Yes |
## OTEL
https://opentelemetry.io/blog/2023/spring-native/
https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/spring-native
## Toolchain
https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html
## Map Struct
given kotlin data class will generate few constructs,
do not set default value for data class, otherwise MapStruct will not assign value to properties.
## Cache
https://spring.io/guides/gs/caching
## OpenFeign
https://docs.spring.io/spring-cloud-openfeign/reference/spring-cloud-openfeign.html#spring-cloud-feign
## Resilience4j
## Build Env
```shell
export JAVA_HOME="/Library/Java/JavaVirtualMachines/graalvm-jdk-21.0.5+9.1/Contents/Home"
export GRAALVM_HOME=$JAVA_HOME
export PATH=$GRAALVM_HOME/bin:$PATH
```
### Build and Run the Demo
```shell
gradle clean nativeCompile
# BUILD SUCCESSFUL in 5m 18s
# 11 actionable tasks: 11 executed
```
#### Runtime info
Package size: ~250M
Duration: Started DemoApplicationKt in 1.121 seconds (process running for 1.132)
#### Running the Native Image
```shell
./build/native/nativeCompile/spring-native-image-demo
```
#### Run Native directly
```shell
gradle clean nativeRun
```