Skip to content

Instantly share code, notes, and snippets.

@bmchild
Created November 16, 2011 21:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmchild/1371444 to your computer and use it in GitHub Desktop.
Save bmchild/1371444 to your computer and use it in GitHub Desktop.
maven-war-plugin using environments
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<import resource="classpath*:/environments/${environment}/applicationContext-${environment}.xml" />
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<warName>ROOT</warName>
<outputDirectory>${user.home}/Deploy/${project.artifactId}/${environment}</outputDirectory>
<containerConfigXML>src/main/resources/environments/${environment}/context.xml</containerConfigXML>
</configuration>
</plugin>
</plugins>
</build>
<!-- profiles -->
<profiles>
<!-- default environment -->
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<environment>local</environment>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<environment>dev</environment>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<environment>test</environment>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<environment>production</environment>
</properties>
</profile>
</profiles>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment