Java maven中文件的条件包含
我有一个JEE6Web应用程序项目。项目结构符合maven约定 现在,我为这个项目引入了其他web.xml文件 因此,它们现在存储在WEB-INF中,如下所示: WEB-INF/Java maven中文件的条件包含,java,build,maven-3,java-ee-6,Java,Build,Maven 3,Java Ee 6,我有一个JEE6Web应用程序项目。项目结构符合maven约定 现在,我为这个项目引入了其他web.xml文件 因此,它们现在存储在WEB-INF中,如下所示: WEB-INF/ |__ A/web.xml |__ B/web.xml 根据属性,构建war以包含适当xml的maven方法是什么 我知道如何在maven中添加自定义属性,但我找不到如何配置maven插件,以便在构建war文件时选择适当的文件 在这种情况下,任何提示/建议/maven最佳实践都是非常受欢迎的 谢
|__ A/web.xml
|__ B/web.xml
根据属性,构建war以包含适当xml的maven方法是什么
我知道如何在maven中添加自定义属性,但我找不到如何配置maven插件,以便在构建war文件时选择适当的文件
在这种情况下,任何提示/建议/maven最佳实践都是非常受欢迎的
谢谢 可以配置为添加和筛选一些外部资源。看
因此,我将使用2 war插件配置制作2 maven,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/webapp/WEB-INF/__A</directory>
<includes>
<include>web.xml</include>
</includes>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<!-- repeat for your second profile -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
org.apache.maven.plugins
maven战争插件
2.3
src/main/webapp/WEB-INF/\uu\A
web.xml
WEB-INF
但我认为更好的解决方案(如果您的项目允许的话)是只保留一个web.xml文件,其中包含一些过滤属性。在这种情况下,您只需配置war插件以启用以下过滤:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/webapp/WEB-INF/__A</directory>
<includes>
<include>web.xml</include>
</includes>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<!-- repeat for your second profile -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
maven战争插件
2.3
真的
可以配置为添加和筛选一些外部资源。看
因此,我将使用2 war插件配置制作2 maven,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/webapp/WEB-INF/__A</directory>
<includes>
<include>web.xml</include>
</includes>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<!-- repeat for your second profile -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
org.apache.maven.plugins
maven战争插件
2.3
src/main/webapp/WEB-INF/\uu\A
web.xml
WEB-INF
但我认为更好的解决方案(如果您的项目允许的话)是只保留一个web.xml文件,其中包含一些过滤属性。在这种情况下,您只需配置war插件以启用以下过滤:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/webapp/WEB-INF/__A</directory>
<includes>
<include>web.xml</include>
</includes>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<!-- repeat for your second profile -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
maven战争插件
2.3
真的