我注意到,当您将 Maven 项目配置为使用属性过滤时,属性过滤似乎在非 Maven IntelliJ“制作”期间也有效。这意味着 Jetty/Tomcat/GWT/Glassfish 的 IntelliJ 运行配置仍将支持您的 maven 资源过滤。
因此,如果我将此添加到我的 pom.xml
:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.properties</include>
<include>**/persistence.xml</include>
</includes>
</resource> ....
它应该在任何 intellij 运行配置开始之前过滤我的 properties 和 peristence.xml 文件中的任何属性。这对于交换 JDBC 引用或文件系统参数非常有用。
我遇到的唯一问题是 IntelliJ 似乎只尊重 src/main/resources 中的过滤,即使我将 pom.xml 更改为其他目录的第二个条目(即:src/integrationtest/resources)。
这一切似乎都是“自动的”。那么它是如何工作的,我可以在哪里(如果有的话)配置它?
最佳答案
IntelliJ IDEA's Make features are capable of filtering Maven resources. However, IntelliJ IDEA yet does not support filtering web resources.
来源:http://www.jetbrains.com/idea/webhelp/maven.html#compile
虽然在整个 intellij webhelp 中没有关于这种支持的更多细节,所以我想它应该像 maven 的 process-resources 阶段一样工作。
您遇到的问题可能是由目录
src/integrationtest/resources
引起的。不遵循 Maven 约定。如果您这样做,也许它会起作用:
src/test/resources/integrationtest/
或者
src/integrationtest
作为测试源(但如果 integrationtest
不是众所周知的约定,它将违反 maven 的 COC 规则)或者
integrationtest
的隔离,请使其成为另一个 maven(子)模块至于过滤目录不同于
src/main/resources
: 过滤 src/main/webapp/META-INF
为我开箱即用。(Maven 3.0.4,Intellij 12.1.4)
关于maven - IntelliJ 的 Maven 过滤支持如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10036400/