An in-depth piece exploring building a modular event-driven microservices architecture, using Spring and Orkes Conductor for orchestration:
In this quick tutorial, we’re going to learn how to configure the server port on Quarkus applications.
2. Configuring Port
By default, similar to many other Java server applications, Quarkus listens to port 8080. In order to change the default server port, we can use the quarkus.http.port property.
Quarkus reads its configuration properties from various sources. Therefore, we can change the quarkus.http.port property from different sources, as well. For instance, we can make Quarkus listen to port 9000 by adding this to our application.properties:
Now, if we send a request to localhost:9000, the server would return some sort of an HTTP response:
>> curl localhost:9000/hello
It’s also possible to configure the port through Java system properties and -D arguments:
>> mvn compile quarkus:dev -Dquarkus.http.port=9000
Listening on: http://localhost:9000
As shown above, the system property is overriding the default port here. In addition to these, we can use environment variables, too:
>> mvn compile quarkus:dev
Here, we’re converting all characters in quarkus.http.port to uppercase and replacing dots with underscores to form the environment variable name.
In this short tutorial, we saw a couple of ways to configure the application port in Quarkus.