TS-*_*TS- 6 maven maven-profiles
我试图有一些变量属性值,并使用Maven配置文件来获得正确的输出.我已经为我的hibernate xml,log4j.properties做了这个,并没有问题.
所以它在项目#1中对我有用,我在/ src/main/resources下有一堆文件.我在maven中设置了属性和资源过滤,如下所示:
<properties>
<log.level>DEBUG</log.level>
</properties>
<profiles>
<profile>
<id>production</id>
<properties>
<log.level>INFO</log.level>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Run Code Online (Sandbox Code Playgroud)
以上工作没有问题.但是,在我的项目#2中 - 我有一些具有可变属性的文件,但是它们位于/ src/main/webapp/WEB-INF下 - 我做的与上面相同,除了指向WEB-INF的目录它不起作用.我在项目#2上尝试将文件放在/ src/main/resources下并且它工作正常.
所以在我看来资源过滤有问题,当文件在/ src/main/webapp/WEB-INF下,但我需要文件在那里,所以它在生成战争时进入WEB-INF文件夹.
有没有人有关于如何做到这一点的指针?
以下是pom.xml中的以下snipet不起作用(资源过滤完全被忽略)
<properties>
<wsdl.url>http://stage/wsdl-url</wsdl.url>
</properties>
<profiles>
<profile>
<id>production</id>
<properties>
<wsdl.url>http://prod/wsdl-url</wsdl.url>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Run Code Online (Sandbox Code Playgroud)
我也有这个问题; 我怀疑<resources>战争插件忽略了POM 的主要部分,因此我想出了直接配置插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<filters>
<filter>filter.properties</filter>
</filters>
<webResources>
<resource>
<directory>WebContent/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3931 次 |
| 最近记录: |