[英]How to Use Different META-INF/context.xml Files For Development and Production Environments
[英]Use specific xml files in production vs development
我们有一个基于maven的Spring Web-Application。 所有网络呼叫都是Restful
,需要身份验证。 但是出于发展目的,做所有需要是痛苦的。 因此,对于开发周期,优选不具有任何安全性。
使用maven标志或其他东西,我们如何为生产和开发生成单独的构建?
所有与安全相关的东西都在web.xml
和applicationContext.xml
。 我们可以有2份(一份用于开发,另一份用于生产)。 在maven构建中,包含必要文件和省略其他文件的最简单方法是什么。
PS:我已经看过使用程序集插件执行上述操作的示例。 我不需要所有这些,只是一个简单的方法来做到这一点。 我正在使用maven-war-plugin
生成war文件。
使用档案。 您可以在pom.xml中定义它们(见下文),然后在构建时包含它们。 对于命令行,这很简单
mvn -P <profile> <target>
大多数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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.