Java 专家轮廓属性和System.getProperty()

Java 专家轮廓属性和System.getProperty(),java,maven,groovy,Java,Maven,Groovy,我想使用不同的maven配置文件为测试需求设置不同的参数。参数是一个URL。测试是在Groovy上进行的。我正在尝试这个: <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation>

我想使用不同的maven配置文件为测试需求设置不同的参数。参数是一个URL。测试是在Groovy上进行的。我正在尝试这个:

<profiles>
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <useUrl>http://url</useUrl>
        </properties>
    </profile>

    <profile>
        <id>another</id>
        <properties>
            <useUrl>http://url2</useUrl>
        </properties>
    </profile>
</profiles>
CodeSystem.getProperty(“useUrl”)将从活动配置文件(http://url
http://url2

系统信息: Maven 3.2.5 Windows 8.1 Intellij IDEA 14.0.2

有人能解释一下为什么配置文件属性不起作用吗?或者我做错了什么?
提前感谢。

Maven属性不是系统属性。

如果需要读取/使用系统属性,则必须在适当的maven插件中明确定义,例如:

  • maven-surefire
    单元测试插件
  • maven jetty插件
    用于jetty servlet容器
  • execmaven插件
    用于使用maven运行应用程序
  • properties maven插件
    供一般使用

谢谢您的解释!
<systemPropertyVariables>
    <baseUrl>${useUrl}</baseUrl>
</systemPropertyVariables>