Maven:包含基于配置文件的资源文件 [英] Maven: include resource file based on profile
问题描述
我正在将Ant webapp项目转换为Maven.我已经完成了大部分工作,但是我一直试图找出如何根据配置文件从不同来源复制一些资源文件的方法.
I'm converting an Ant webapp project over to Maven. I have most of it working, but I'm stuck trying to figure out how to copy some resource files from different sources based on the profile.
我有src/main/resources/persistence-{dev, prod}.xml
.其中之一需要作为WEB-INF/classes/META-INF/persistence.xml
包含在war文件中.
I have src/main/resources/persistence-{dev, prod}.xml
. One of these needs to be included in the war file as WEB-INF/classes/META-INF/persistence.xml
.
我希望在dev配置文件处于活动状态时复制dev版本,而在prod处于活动状态时复制prod版本.
I would like the dev version to be copied when the dev profile is active, and the prod version when prod is active.
推荐答案
Just use the maven resources plugin like so http://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html and have a property for the file name or extension set in a profile.
这篇关于Maven:包含基于配置文件的资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!