我有以下项目结构:
src/
main/
java/
...
resources/
META-INF/
context.xml
persistence.xml
webapp/
WEB-INF/
web.xml
...
...
test/
...
pom.xml(具体来说,build
部分)如下所示:
<build>
<finalName>...</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<containerConfigXML>src/main/resources/META-INF/context.xml</containerConfigXML>
</configuration>
</plugin>
</plugins>
</build>
问题是 context.xml
在生成的 WAR 中被加倍了。它出现在
/META-INF
- 这是它的正确位置,并且/WEB-INF/classes/META-INF
。我看到它像任何其他资源一样从resources
文件夹复制到这里。
应用程序部署完美,但这种重复确实让我很困扰。我的设置有什么问题?
最佳答案
添加 <resources>
<build>
下的元素, 并明确排除该文件。
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>META-INF/context.xml</exclude>
</excludes>
</resource>
</resources>
关于java - Maven 项目中重复的 context.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16542902/