Files
Jens Schauder 7c696ac196 Polishing.
Update README files to reference all the examples for Spring Data JDBC.
Also fix a typo in another README.

See #675
2023-11-07 15:50:51 +01:00
..
2022-12-12 11:16:15 +01:00
2022-12-12 11:16:15 +01:00
2023-11-07 15:50:51 +01:00

== Spring Data JDBC - GraalVM native image

This example compiles a basic Spring Data JDBC application 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'}
...
```