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

标签 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

使用服务器参数

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

端口号已更改,但开始 目标并未完成。

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]

要跟踪的问题

最佳答案

使用 wildfly maven 插件,您可以将任何环境或 jvm 变量传递给服务器进程。 JBoss/Wildfly 有一个端口偏移量的概念,因此您可以将自定义值添加到所有默认端口号值,例如以端口偏移量 100 启动服务器,将导致 http 端口监听 8180。要使用 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 端口在套接字绑定(bind)中定义如下:

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

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

关于maven - 如何使用 Maven 更改 WildFly 监听端口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44515837/

相关文章:

java - 如何诊断野蝇10.1下降的原因

java - WildFly8 EJB3 MySQL 加载驱动程序不起作用

java - 忽略了 Wildfly 安全约束

json - JSON 模式验证工具

Maven + hudson + Nexus : Access to SNAPSHOT Build Number

java - 如何让程序找到属性文件?

java - maven-ear-plugin 忽略模块的解包选项