How can I configure the port a Quarkus application runs on?

时光毁灭记忆、已成空白 提交于 2019-12-05 23:38:12

问题


I would like my Quarkus application to run on a port other than the default. How can I accomplish that?


回答1:


The Quarkus configuration property to be used is quarkus.http.port (the default value is 8080). If this property is set in application.properties then that value will be used.

The property can also be overridden at runtime as follows:

When running a Quarkus application in JVM mode you can set the port using the quarkus.http.port System property. For example:

java -Dquarkus.http.port=8081 -jar example-runner.java

The same property applies to GraalVM Native Mode images. For example:

./example-runner -Dquarkus.http.port=8081



回答2:


To complement geoand’s answer, you can use the same property for mvn quarkus:dev. Unfortunately you cannot directly set it in a profile in ~/.m2/settings.xml to avoid the need to type it each time (for example because Microk8s binds 8080), but you can set it via jvm.args:

<profiles>
    <profile>
        <id>microk8s-quarkus-dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <jvm.args>-Dquarkus.http.port=8090</jvm.args>
        </properties>
    </profile>
</profiles>

Alternately, you could configure this in project sources:

echo '%dev.quarkus.http.port=8090' >> src/main/resources/application.properties

though this would not be shared across projects, and might be unwanted by other developers of the same project.



来源:https://stackoverflow.com/questions/55043620/how-can-i-configure-the-port-a-quarkus-application-runs-on

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!