Create basic project
Let's create the basic Quarkus Hello World application and include the necessary spring extensions. Click this command to create the project:
mvn io.quarkus:quarkus-maven-plugin:1.0.0.CR1:create \
This will use the Quarkus Maven Plugin and generate a basic Maven project for you in the
fruit-taster subdirectory and include the following extensions to enable Spring annotations and APIs:
- spring-data-jpa - Adds Spring Data annotations like
@CrudRepositoryallowing integration with database-backed JPA repositories
- spring-web - Adds Spring Web annotations like
- spring-di - Adds Spring DI annotations like
- jdbc-postgres - Driver for Postgresql database. Note this is the
jdbcvariant. Reactive programmers may be interested in the Reactive Postgres Client.
Start the database
We'll need a locally running database to test our app during Live Coding. Click the following command to start one in the background:
docker run --ulimit memlock=-1:-1 --rm=true --memory-swappiness=0 \
--name postgres-database -e POSTGRES_USER=sa \
-e POSTGRES_PASSWORD=sa -e POSTGRES_DB=fruits \
-p 5432:5432 postgres:10.5 >& /dev/null &
Start the app
First, switch to the directory in which the app was built:
Let's begin Live Coding. Click on the following command to start the app in Live Coding mode:
mvn compile quarkus:dev
You should see:
INFO [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation INFO [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 1283ms INFO [io.quarkus] (main) Quarkus x.xx.x started in 1.988s. Listening on: http://[::]:8080 INFO [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, jdbc-postgresql, narayana-jta, resteasy, spring-data-jpa, spring-di, spring-web]
The first time you build the app, new dependencies may be downloaded via maven. This should only happen once, after that things will go even faster.
Note the amazingly fast startup time! The app is now running "locally" (within the Linux container in which this exercise runs).
Test that the app is running by accessing the simple
cd /root/projects/quarkus/fruit-taster && \
You may need to click this command again in case it doesn't execute properly on first click
you should see
This app doesn't use any Spring annotations yet. You'll live code those in the next few steps while the app continues to run.