【发布时间】:2015-03-10 19:20:27
【问题描述】:
我想使用不同的 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>
还有 groovy 代码:baseUrl = System.getProperty("useUrl")
System.getProperty("useUrl") 始终返回“null”。
但是如果我像这样在surefire插件中进行配置:
<systemPropertyVariables>
<baseUrl>${useUrl}</baseUrl>
</systemPropertyVariables>
代码System.getProperty("useUrl") 将完全返回我的预期 - 来自活动配置文件的值(http://url 或 http://url2)。
系统信息: Maven 3.2.5 视窗 8.1 Intellij IDEA 14.0.2
有人能解释一下为什么配置文件属性不起作用吗?或者我做错了什么? 提前致谢。
【问题讨论】: