Java 在生产和开发中使用特定的xml文件
我们有一个基于maven的SpringWeb应用程序。所有web调用都是Restful的,需要身份验证。但为了发展的目的,做所有必要的事情是一种痛苦。因此,对于开发周期,最好不要有任何安全性 使用maven标志或其他东西,我们如何为生产和开发生成单独的构建 所有与安全相关的内容都在Java 在生产和开发中使用特定的xml文件,java,spring,maven,Java,Spring,Maven,我们有一个基于maven的SpringWeb应用程序。所有web调用都是Restful的,需要身份验证。但为了发展的目的,做所有必要的事情是一种痛苦。因此,对于开发周期,最好不要有任何安全性 使用maven标志或其他东西,我们如何为生产和开发生成单独的构建 所有与安全相关的内容都在web.xml和applicationContext.xml中。我们可以有两份(一份用于开发,另一份用于生产)。在maven构建中,最简单的方法是什么来包含必要的文件而忽略其他文件 PS:我见过使用汇编插件进行上述操作
web.xml
和applicationContext.xml
中。我们可以有两份(一份用于开发,另一份用于生产)。在maven构建中,最简单的方法是什么来包含必要的文件而忽略其他文件
PS:我见过使用汇编插件进行上述操作的示例。我不需要所有这些,只需要一个简单的方法。我正在使用
maven-war-plugin
生成war文件。使用配置文件。在pom.xml(见下文)中定义它们,然后在构建时包含它们。对于命令行,这很简单
mvn -P <profile> <target>
mvn-P
大多数IDE都提供了一种设置概要文件的方法
pom.xml:
<properties>
<!-- default -->
<webXmlPath>src\main\webapp\WEB-INF\web-test.xml</webXmlPath>
</properties>
<profiles>
<profile>
<id>Production</id>
<properties>
<webXmlPath>src\main\webapp\WEB-INF\web.xml</webXmlPath>
</properties>
<build>
<finalName>${artifactId}</finalName>
</build>
</profile>
<profile>
<id>Accept</id>
<properties>
<webXmlPath>src\main\webapp\WEB-INF\web-accept.xml</webXmlPath>
</properties>
<build>
<finalName>${artifactId}-accept</finalName>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webXml>${webXmlPath}</webXml>
</configuration>
</plugin>
</plugins>
</build>
src\main\webapp\WEB-INF\WEB-test.xml
生产
src\main\webapp\WEB-INF\WEB.xml
${artifactId}
接受
src\main\webapp\WEB-INF\WEB-accept.xml
${artifactId}-接受
org.apache.maven.plugins
maven战争插件
2.3
${webXmlPath}