To compile and run this demo you will need:
- GraalVM - see our Building native image guide
- Apache Maven
3.5.3+
In addition, you will need either a PostgreSQL database, or Docker to run one.
If you don't have GraalVM installed, you can download it here:
https://github.com/oracle/graal/releases
Installing GraalVM is very similar to installing any other JDK:
just unpack it, add it to your path, and point the JAVA_HOME
and GRAALVM_HOME
environment variables to it.
You should then use this JDK to run the Maven build.
After having set GraalVM as your JVM, launch the Maven build on the checked out sources of this demo:
mvn package
First we will need a PostgreSQL database; you can launch one easily if you have Docker installed:
docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name quarkus_test -e POSTGRES_USER=quarkus_test -e POSTGRES_PASSWORD=quarkus_test -e POSTGRES_DB=quarkus_test -p 5432:5432 postgres:11.5
Alternatively you can setup a PostgreSQL instance in any another way.
The connection properties of the Agroal datasource are configured in the standard Quarkus configuration file, which you will find in
src/main/resources/application.properties
.
To run the application in interactive mode (developer mode):
mvn compile quarkus:dev
In this mode you can make changes to the code and have the changes immediately applied, by just refreshing your browser.
Hot reload works even when modifying your JPA entities.
Try it! Even the database schema will be updated on the fly.
When you're done playing with "dev-mode" you can run it as a standard Java application.
First compile it:
mvn package
Then run it:
java -jar ./target/using-spring-data-jpa-1.0-SNAPSHOT-runner.jar
Have a look at how fast it boots.
Or measure total native memory consumption...
This same demo can be compiled into native code: no modifications required.
This implies that you no longer need to install a JVM on your production environment, as the runtime technology is included in the produced binary, and optimized to run with minimal resource overhead.
Compilation will take a bit longer, so this step is disabled by default;
let's build again by enabling the native
profile:
mvn package -Dnative
After getting a cup of coffee, you'll be able to run this binary directly:
./target/using-spring-data-jpa-1.0-SNAPSHOT-runner