Quarkus – Change the HTTP port
By default, the Quarkus application starts on HTTP port 8080.
$ mvn compile quarkus:dev
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-01-13 17:28:39,373 INFO [io.quarkus] (Quarkus Main Thread) quiz 1.0 on JVM (powered by Quarkus 1.10.5.Final)
started in 1.093s. Listening on: http://localhost:8080
2021-01-13 17:28:39,375 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2021-01-13 17:28:39,376 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy, resteasy-jackson]
P.S Tested with Quarkus 1.10.5.Final.
1. Change the HTTP port
In Quarkus, we can use property quarkus.http.port
to override the HTTP port (the default value is 8080).
# Change the HTTP port to 8888
quarkus.http.port=8888
We also can override the HTTP port at runtime via the same property.
# jar file
$ java -Dquarkus.http.port=8888 -jar target/app-runner.jar
# native build
./app-runner -Dquarkus.http.port=8888
2. Change the HTTP port by profiles
2.1 This example shows how to change the HTTP port based on different profiles.
By default, Quarkus has three profiles:
dev
– Activated when in development mode (i.e.quarkus:dev
)test
– Activated when running testsprod
– The default profile when not running in development or test mode
2.2 The Quarkus supports the following syntax to change the property value based on profiles.
%{profile}.config.key=value
For example:
quarkus.http.port=8080
%dev.quarkus.http.port=8888
%test.quarkus.http.port=7777
%server1.quarkus.http.port=6666
If we compile the project with quarkus:dev
, the profile is dev
, and the HTTP port will be 8888.
# %dev.quarkus.http.port=8888
$ mvn compile quarkus:dev
We also can use property quarkus-profile
to pass a specified profile to the Quarkus application. In this example, the profile is server1
, and the HTTP port will be 6666.
# %server1.quarkus.http.port=6666
$ mvn -Dquarkus-profile=server1 compile quarkus:dev
If we package and run the .jar
, the default profile is prod
, and the HTTP port will be 8080.
# quarkus.http.port=8080
$ mvn package
$ java -jar target/app-runner.jar
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-01-13 18:01:40,812 INFO [io.quarkus] (main) quiz 1.0 on JVM (powered by Quarkus 1.10.5.Final) started in 0.624s.
Listening on: http://0.0.0.0:8080
2021-01-13 18:01:40,814 INFO [io.quarkus] (main) Profile prod activated.
2021-01-13 18:01:40,815 INFO [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jackson]
Download Source Code
$ git clone https://github.com/mkyong/quarkus