java - JNDI Configuration in context.xml based on Maven profile -
given
i'm new doing "funky stuff" maven , i've run quandary. have 2 separate servers need deploy , each different jdni resource profile defined in context.xml
my file structure such: (although can change if there better way)
src/main/webapp/meta-inf/context.xml src/main/webapp/meta-inf/context.devel.xml src/main/webapp/meta-inf/context.prod.xml depending on deployment target use appropriate context.target.xml file.
question
i understand need setup 2 different build profiles such as:
<profiles> <profile> <id>prod</id> </profile> <profile> <id>devel</id> </profile> </profiles> but here confused best solution is. understand war plugin can exclude context.xml point onwards i'm confused do.
is there way have variable inside of context.xml can have maven "write" opposed having 2 different configuration files.
any suggestions?
here hints.
- you need 1
context.xml. - replace server specific entries in
context.xmlcustom maven properties. example: ${myserver} or ${dbuser} - define these properties in profiles this
<profiles> <profile> <id>prod</id> <properties> <myserver>srv-prod.yourcompany.com</myserver> <dbuser>james</dbuser> </properties> </profile> <profile> <id>devel</id> <properties> <myserver>srv-devel.yourcompany.com</myserver> <dbuser>richard</dbuser> </properties> </profile> </profiles> - configure maven-war-plugin properly.
<plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-war-plugin</artifactid> <version>2.5</version> <configuration> <filteringdeploymentdescriptors>true</filteringdeploymentdescriptors> <webresources> <resource> <directory>src/main/webapp/meta-inf</directory> <targetpath>/meta-inf</targetpath> <filtering>true</filtering> </resource> </webresources> </configuration> </plugin> </plugins> - activate appropriate profile within maven build. example, call
mvn -pprod clean packageon command line. or activate needed profile in ide.devluse-pdevlinstead.
Comments
Post a Comment