Is it possible to supply Tomcat6's context.xml file via the Maven Cargo plugin?

前端 未结 3 1558
野的像风
野的像风 2020-12-10 05:44

I\'d like to keep Tomcat\'s context.xml file out of my WAR file\'s META-INF directory if possible. Can this be done with Maven\'s cargo plugin? I can\'t seem to find the c

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-10 06:22

    Eureka! After many days of studying this problem I finally found a very effective solution. The key is to take your Tomcat XML context fragment file and use the element of cargo to drop it in the conf/Catalina/localhost directory with the name context.xml.default. The only downside is that this will make your context definitions available to all web-apps, but this shouldn't really matter only Cargo is using this Tomcat instance thus there is no other web-app.

    Here's the configuration:

     
        standalone
        
           ${tomcat6.port}
        
        
          
            com.myapp
            myapp-war
            war
            
                   ${tomcat6.context}
            
           
         
        
           
             ${basedir}/../config/tomcat-context.xml
             conf/Catalina/localhost/
             context.xml.default
           
        
    
    

    The net result is no more bogus WAR modules for testing only, and no more merging of WARs. Hope this helps somebody.

提交回复
热议问题