是否可以通过Maven Cargo插件提供Tomcat6的context.xml文件? [英] Is it possible to supply Tomcat6's context.xml file via the Maven Cargo plugin?

查看:101
本文介绍了是否可以通过Maven Cargo插件提供Tomcat6的context.xml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可能的话,我想将Tomcat的context.xml文件排除在WAR文件的META-INF目录之外.可以使用Maven的cargo插件完成此操作吗?我似乎找不到正确的配置.

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 correct configuration.

推荐答案

尤里卡!经过数天的研究,我终于找到了一个非常有效的解决方案.关键是获取Tomcat XML上下文片段文件,并使用cargo的<configfiles>元素将其拖放到名称为context.xml.defaultconf/Catalina/localhost目录中.唯一的缺点是,这将使您的上下文定义可用于所有Web应用程序,但这并不重要,仅Cargo使用此Tomcat实例,因此没有其他Web应用程序.

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 <configfiles> 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.

这是配置:

<configuration> <!-- Deployer configuration -->
    <type>standalone</type>
    <properties>
       <cargo.servlet.port>${tomcat6.port}</cargo.servlet.port>
    </properties>
    <deployables>
      <deployable>
        <groupId>com.myapp<groupId>
        <artifactId>myapp-war</artifactId>
        <type>war</type>
        <properties>
               <context>${tomcat6.context}</context>
        </properties>
       </deployable>
     </deployables>
    <configfiles>
       <configfile>
         <file>${basedir}/../config/tomcat-context.xml</file>
         <todir>conf/Catalina/localhost/</todir>
         <tofile>context.xml.default</tofile>
       </configfile>
    </configfiles>
</configuration>

最终结果是不再有仅用于测试的伪造WAR模块,也不再有WAR的合并.希望这对某人有帮助.

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

这篇关于是否可以通过Maven Cargo插件提供Tomcat6的context.xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆