You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Open Liberty开发模式集成测试获取http.port问题(已解决)

问题已解决:Open Liberty集成测试获取系统属性异常问题不再复现

我在进行JEE Open Liberty集成测试时,需要动态获取端口与应用上下文根,实现代码如下:

String port = System.getProperty("http.port");
String context = System.getProperty("context.root");

在IntelliJ中运行测试时该逻辑正常工作,pom.xml中定义的变量可通过maven-failsafe-plugin传入JVM,测试代码能正常读取。此前曾出现过服务器启动后按Enter以「开发模式」运行测试时,上述两个属性均返回null的情况,当时的相关配置如下:

pom.xml属性配置

<properties>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <liberty.var.http.port>9080</liberty.var.http.port>
    <liberty.var.https.port>9443</liberty.var.https.port>
    <liberty.var.app.context.root>myapp</liberty.var.app.context.root>
    <junit.version>5.10.0</junit.version>
</properties>

Maven Failsafe插件配置

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>3.3.0</version>
    <configuration>
        <systemPropertyVariables>
            <http.port>${liberty.var.http.port}</http.port>
            <app.context.root>${liberty.var.app.context.root}</app.context.root>
        </systemPropertyVariables>
    </configuration>
</plugin>

内容的提问来源于stack exchange,提问作者Thomas Auinger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 03:27:19