本文介绍了如何使用Maven更改WildFly监听端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using wildfly-maven-plugin for my integration tests.

如何更改端口默认编号(8080、8443)?

How can I change port default numbers(8080, 8443)?

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

I couldn't find any configuration property for those port numbers.

更新

我尝试了语法的,但端口号仍为默认值.

I tried yntelectual's answer but ports numbers are still in their default values.

我找到了和端口号被改变了.但是启动目标失败并产生无法在XX秒内启动"的信号,可能是某些信令过程不知道更改的端口.

I found this and the port numbers are changed. But the start goal fails yielding "failed to start in XX seconds" may some signaling procedure doesn't know the changed port.

    <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目标未完成.

Port numbers changed but the start goal doesn't finish.

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]

要跟踪

  • https://issues.jboss.org/browse/WFMP-12
  • https://issues.jboss.org/browse/WFMP-14
  • Issues to track

    • https://issues.jboss.org/browse/WFMP-12
    • https://issues.jboss.org/browse/WFMP-14
    • 推荐答案

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

      With wildfly maven plugin, you can pass any environment or jvm variable to the server process. JBoss/Wildfly has a notion of port-offset, so that you can add a custom value to all default port number values, e.g. starting the Server with port offset 100, will result in http port listening on 8180. To do that with maven plugin simply specify it as 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端口,如下所示:

      If you want to override any other value, you just need to know its name. Looking at the wildfly config, you will see that the http port for example, is defined in socket binding like so:

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

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

      The expression specifies, that if a variable with the name jboss.http.port exists, it will be used as the value. Otherwise the server will fallback to the value specified after colon- :8080. Similarly, https port can be overridden by setting property jboss.https.port. For more info just browse the configuration file(default is standalone.xml) and wildfly plugin docs.

      这篇关于如何使用Maven更改WildFly监听端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 18:36