如何使用Maven更改WildFly监听端口?

时间:2017-06-13 08:13:48

标签: maven wildfly wildfly-maven-plugin

我正在使用wildfly-maven-plugin进行集成测试。

如何更改端口默认号码(8080,8443)?

我找不到这些端口号的任何配置属性。

更新

我尝试了yntelectualanswer,但端口号仍然是默认值。

我发现this并且端口号已更改。但是起始目标未能产生“在XX秒内未能启动”可能某些信令程序不知道已更改的端口。

    <executions>
      <execution>
        <id>wildfly-start</id>
        <phase>pre-integration-test</phase>
        <goals>
          <goal>start</goal>
        </goals>
      </execution>
      <execution>
        <id>wildfly-deploy</id>
        <phase>pre-integration-test</phase>
        <goals>
          <goal>deploy</goal>
        </goals>
      </execution>
      <execution>
        <id>wildfly-undeploy</id>
        <phase>post-integration-test</phase>
        <goals>
          <goal>undeploy</goal>
        </goals>
      </execution>
      <execution>
        <id>wildfly-shutdown</id>
        <phase>post-integration-test</phase>
        <goals>
          <goal>shutdown</goal>
        </goals>
      </execution>
    </executions>

使用jvmArgs

<configuration>
  <jvmArgs>-Djboss.socket.binding.port-offset=40000</jvmArgs>
</configuration>

端口号仍为默认值。

14:25:34,244 INFO  ... Undertow HTTP listener default listening on 127.0.0.1:8080
14:25:35,107 INFO  ... Undertow HTTPS listener https listening on 127.0.0.1:8443
14:25:40,183 INFO  ... Http management interface listening on http://127.0.0.1:9990/management
14:25:40,183 INFO  ... Admin console listening on http://127.0.0.1:9990

使用server-args

<configuration>
  <server-args>
    <server-arg>-Djboss.socket.binding.port-offset=40000</server-arg>
  </server-args>
</configuration>

端口号已更改,但start目标尚未完成。

14:29:35,535 INFO  ... Undertow HTTP listener default listening on 127.0.0.1:48080
14:29:36,543 INFO  ... Undertow HTTPS listener https listening on 127.0.0.1:48443
14:29:41,535 INFO  ... Http management interface listening on http://127.0.0.1:49990/management
14:29:41,535 INFO  ... Admin console listening on http://127.0.0.1:49990
BUILD FAILURE
------------------------------------------------------------------------
14:30:07,345 INFO  ... Undertow HTTPS listener https stopped, was bound to 127.0.0.1:48443
14:30:07,347 INFO  ... Undertow HTTP listener default suspending
14:30:07,357 INFO  ... Undertow HTTP listener default stopped, was bound to 127.0.0.1:48080
14:30:07,359 INFO  ... Undertow 1.4.0.Final stopping
14:30:07,365 INFO  ... WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) stopped in 34ms
[INFO] Final Memory: 34M/460M
------------------------------------------------------------------------
Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.2.0.Alpha5:start (wildfly-start) on project ...
The server failed to start: 
The server did not start within 60 seconds. -> [Help 1]

要跟踪的问题

2 个答案:

答案 0 :(得分:5)

使用wildfly maven插件,您可以将任何环境或jvm变量传递给服务器进程。 JBoss / Wildfly有一个端口偏移的概念,因此您可以将自定义值添加到所有默认端口号值,例如使用端口偏移量100启动服务器将导致在8180上侦听http端口。要使用maven插件执行此操作,只需将其指定为jvm arg:

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <configuration>
        <jvmArgs>-Djboss.socket.binding.port-offset=100</jvmArgs>
    </configuration>
</plugin>

如果要覆盖任何其他值,只需知道其名称即可。查看wildfly配置,您将看到http端口,例如,在套接字绑定中定义如下:

<socket-binding name="http" port="${jboss.http.port:8080}"/>

表达式指定,如果存在名为jboss.http.port的变量,则将其用作值。否则,服务器将回退到冒号:8080后指定的值。同样,可以通过设置属性jboss.https.port来覆盖https端口。有关详细信息,请浏览配置文件(默认为standalone.xml)和wildfly plugin docs

答案 1 :(得分:0)

您正在接收&#34;未能在XX秒内启动&#34;因为你必须指定maven插件的管理端口:

在你的情况下

<configuration>
  <server-args>
    <server-arg>-Djboss.socket.binding.port-offset=40000</server-arg>
  </server-args>
  <port>49990</port>
</configuration>

根据您的使用情况,最好逐个设置端口

<configuration>
  <server-args>
    <server-arg>-Djboss.http.port=8080</server-arg>
    <server-arg>-Djboss.https.port=8443</server-arg>
    <server-arg>-Djboss.management.http.port=9991</server-arg>
    <server-arg>-Djboss.management.https.port=9993</server-arg>
  </server-args>
  <port>9991</port>
</configuration>

response James R. Perkinsexplains中,为什么在配置中需要<port>