Experiments with Quarkus
  • Java 58.7%
  • HTML 40.2%
  • Dockerfile 1.1%
Find a file
Philip Oswald 53fc467e50
All checks were successful
/ ci-build (pull_request) Successful in 1m17s
/ ci-build (push) Successful in 30s
Fix Junit artifact
2026-03-09 23:34:18 +01:00
.forgejo/workflows Upgrade to Quarkus 3.31, Java 25 2026-02-17 22:17:24 +01:00
src Add support for XML with REST 2026-02-18 00:50:40 +01:00
.dockerignore Create application with similar feature set as sample-ratpack 2020-10-09 23:28:02 +02:00
.gitignore Ignore IntelliJ project files 2025-12-29 15:12:30 +01:00
pom.xml Fix Junit artifact 2026-03-09 23:34:18 +01:00
README.md Add support for XML with REST 2026-02-18 00:50:40 +01:00
renovate.json Add renovate.json 2023-09-20 00:03:55 +02:00

sample-quarkus

Experiments with Quarkus, featuring:

  • Static web content
  • Dynamic web content using JAX-RS and Qute
  • REST endpoints using JAX-RS
  • Postgres database using JPA and Hibernate

Run Standalone

$ mvn clean verify
$ export APP_SAMPLE_CONFIG=ValueFromShell
$ java \
  -Dquarkus.http.port=8081 \
  -Dquarkus.http.auth.session.encryption-key=mysecretforsession \
  -Dquarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/mydb \
  -Dquarkus.datasource.username=myuser \
  -Dquarkus.datasource.password=mypassword \
  -jar target/quarkus-app/quarkus-run.jar

There is no main class to run from the IDE. Use Dev Mode with Maven instead!

Run with Docker

$ mvn clean verify -P docker
$ docker run -it --name sample-quarkus --rm \
  -p 8081:8080 \
  -e QUARKUS_HTTP_AUTH_SESSION_ENCRYPTION_KEY=mysecretforsession \
  -e QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://surin.home:5432/mydb \
  -e QUARKUS_DATASOURCE_USERNAME=myuser \
  -e QUARKUS_DATASOURCE_PASSWORD=mypassword \
  -e APP_SAMPLE_CONFIG=ValueFromDockerRun \
  philip/sample-quarkus:0.1.0-SNAPSHOT

Run with Dev Mode

$ mvn quarkus:dev \
  -Dquarkus.http.port=8081 \
  -Dquarkus.http.auth.session.encryption-key=mysecretforsession \
  -Dquarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/mydb \
  -Dquarkus.datasource.username=myuser \
  -Dquarkus.datasource.password=mypassword \
  -Dquarkus.hibernate-orm.database.generation=update

Note: JVM System Properties can be passed as normal command line arguments (using -D...=... syntax).

Run Natively

$ mvn clean verify -P native
$ target/sample-quarkus-0.1.0-SNAPSHOT-runner \
  -Dquarkus.http.port=8081 \
  -Dquarkus.http.auth.session.encryption-key=mysecretforsession \
  -Dquarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/mydb \
  -Dquarkus.datasource.username=myuser \
  -Dquarkus.datasource.password=mypassword

Note: JVM System Properties can be passed as normal command line arguments (using -D...=... syntax).

Verify native executable dependencies:

$ ldd target/sample-quarkus-0.1.0-SNAPSHOT-runner
    linux-vdso.so.1 (0x00007ffdbb115000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2618ae6000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2618ae1000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2618adc000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2618ad7000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f26188af000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f2618b18000)

URLs

$ curl 'http://localhost:8081/app/rest/sample/time' -i
$ curl 'http://localhost:8081/app/rest/sample/config' -i
$ curl 'http://localhost:8081/app/rest/sample/echo-xml' -i -X POST \
  -H 'content-type: application/xml' \
  -d '<echoRequest><input>This is CURL</input></echoRequest>'
$ curl 'http://localhost:8081/app/rest/sample/echo-json' -i -X POST \
  -H 'content-type: application/json' \
  -d '{"input":"This is CURL"}'
$ curl 'http://localhost:8081/app/rest/tasks' -i
$ curl 'http://localhost:8081/app/rest/tasks' -i -X POST \
  -H 'content-type: application/json' \
  -d '{"title":"Some task","description":"This is CURL","done":true}'
$ curl 'http://localhost:8081/app/rest/tasks/5b89f266-c566-4d1f-8545-451bc443cf26' -i
$ curl 'http://localhost:8081/app/rest/tasks/5b89f266-c566-4d1f-8545-451bc443cf26' -i -X PUT \
  -H 'content-type: application/json' \
  -d '{"title":"Some updated task","description":"This is still CURL","done":false}'
$ curl 'http://localhost:8081/app/rest/tasks/5b89f266-c566-4d1f-8545-451bc443cf26' -i -X DELETE

Security

See SQL DDL for Postgres.

Create passwords for form-based authentication (table user_):

$ java -cp 'target/quarkus-app/lib/boot/*:target/quarkus-app/lib/main/*:target/classes' \
  com.github.phoswald.sample.security.PasswordUtility