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.xml custom 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> 
<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 package on command line. or activate needed profile in ide. devl use -pdevl instead.

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -