【问题标题】:maven-surefire-plugin system properties and eclipse integration?maven-surefire-plugin 系统属性和eclipse集成?
【发布时间】:2026-02-16 13:05:01
【问题描述】:

我在 maven 的 pom.xml 中设置系统属性以确保执行。 Eclipse 忽略了这些。有什么办法可以解决这个问题吗?

特别是我使用 basedir 属性来确定文件位置,即构建目录等。

我不想将测试作为“maven 测试”运行,因为这很慢。

更新

我现在使用测试类的资源位置来确定磁盘上的项目位置:

https://github.com/jjYBdx4IL/misc/blob/master/env-utils/src/main/java/com/github/jjYBdx4IL/utils/env/Maven.java#L64

根本不需要配置

<dependency>
    <groupId>com.github.jjYBdx4IL.utils</groupId>
    <artifactId>env-utils</artifactId>
    <version>1.0</version>
</dependency>

【问题讨论】:

    标签: java eclipse maven junit maven-surefire-plugin


    【解决方案1】:

    我假设你所说的,当你在命令行运行 maven 时,你已经设置了环境变量,maven 会选择它。如果是这种情况,那么either passing it along on the command linesetting the system properties 似乎可能是您正在寻找的解决方案。另一件事是,确保您使用的是“project.basedir”,而不仅仅是“basedir”。看 here 用于属性名称

    【讨论】:

    • 如果我只将测试作为 maven 测试运行,那么它就可以工作。但是以这种方式运行测试很慢。