48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
== Spring Data JDBC - GraalVM native image
|
|
|
|
This example compiles a basic Spring Data JDBC appication into a GraalVM native image.
|
|
|
|
=== Install GraalVM & native image tooling
|
|
|
|
Download and install GraalVM using https://sdkman.io/[SDKMAN!].
|
|
|
|
```
|
|
$> sdk install java <recent version>.r17-grl
|
|
$> gu install native-image
|
|
```
|
|
|
|
=== Compile to native image
|
|
|
|
The maven build uses a dedicated profile `native` to trigger the native image creation.
|
|
|
|
```
|
|
$> maven clean package -P native
|
|
```
|
|
|
|
This will create the native executable in the target folder.
|
|
|
|
=== Run the image
|
|
|
|
Run the image directly from your console as shown below.
|
|
This will print results of crud functions invoked via a `CommandLineRunner`.
|
|
|
|
```
|
|
$> ./target/spring-data-jdbc-graalvm-native
|
|
|
|
. ____ _ __ _ _
|
|
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
|
|
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
|
|
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
|
|
' |____| .__|_| |_|_| |_\__, | / / / /
|
|
=========|_|==============|___/=/_/_/_/
|
|
:: Spring Boot :: (v3.0.0-SNAPSHOT)
|
|
|
|
INFO 82562 --- [ main] e.s.j.g.GraalvmNativeApplication : Starting GraalvmNativeApplication using Java 17.0.4 with PID 82562
|
|
INFO 82562 --- [ main] e.s.j.g.GraalvmNativeApplication : Started GraalvmNativeApplication in 0.042 seconds (process running for 0.061)
|
|
insertAuthors(): author1 = Author{name='Josh Long'}
|
|
insertAuthors(): author2 = Author{name='Martin Kleppmann'}
|
|
listAllAuthors(): author = Author{name='Josh Long'}
|
|
Book{title='Reactive Spring'}
|
|
...
|
|
```
|