[英]StackOverflowError when running JUnit tests in Intellij
[英]IntelliJ: activate Maven profile when running Junit tests
我已经声明了一些特定于 Maven 配置文件的属性。 我的 pom.xml 的一部分:
<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<my.properties.file>foo.xml</my.properties.file>
</properties>
</profile>
<profile>
<id>ci</id>
<properties>
<my.properties.file>bar.xml</my.properties.file>
</properties>
</profile>
</profiles>
当我通过 IntelliJ IDEA 2016 启动 Junit 测试时,我在使用“ci”Maven 配置文件时遇到了一些问题。
我通过“Maven 项目”面板激活我的配置文件,然后开始测试。 问题是“my.properties.file”属性值等于“foo.xml”,而不是“bar.xml”。
我对命令行没问题(我可以使用“-Pci”标志)。 我如何告诉 IntelliJ 使用“ci”配置文件? 谢谢。
您应该将配置文件添加到Maven setting.xml文件中(您应该在路径$ {YOUR_MAVEN_HOME} \\ apache-maven-3.1.1 \\ conf \\ setting.xml中找到它)。 然后,您必须打开intellij,单击视图>工具窗口> Maven项目。 在那里,您应该看到您的个人资料(ci和发布)并选择正确的个人资料。
希望这可以帮到你。
终于解决了。
<profile>
<id>profile-to-be-activated-on-build</id>
<activation>
<activeByDefault>false</activeByDefault><!-- on your flavor -->
<property>
<name>mvn-profile-env-var-trigger</name>
</property>
</activation>
</profile>
转到 JUnit 默认配置文件(又名配置模板)。 添加到 JVM 参数中:
-Dmvn-profile-env-var-trigger
您可能需要在 IDE 中手动重新加载 maven 配置文件。
还要确保 [Settings > Build Tools > Maven > Running tests] envVars 被选中(或更好的一切)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.