【问题标题】:How do I create a jetty 6 and jetty 7 compatible jetty-web.xml file in the same war file?如何在同一个 war 文件中创建 jetty 6 和 jetty 7 兼容的 jetty-web.xml 文件?
【发布时间】:2011-10-04 11:16:12
【问题描述】:

在 Jetty 6 中,我需要创建一个包含以下内容的 WEB-INF/jetty-web.xml 文件:

<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">

但在 Jetty 7 中,我需要完全相同的文件 WEB-INF/jetty-web.xml 来包含此内容:

<Configure id="webAppCtx" class="org.eclipse.jetty.webapp.WebAppContext">

两个文件不同(org.mortbayorg.eclipse)。如何创建 1 个同时兼容 jetty 6 和 jetty 7 的 war 文件?

【问题讨论】:

    标签: jetty jboss-weld appserver


    【解决方案1】:

    我不知道这是否可以在一个文件中完成,但您可以使用 ANT 构建脚本来创建两个特定于版本的 WAR(如果您已经这样做了,那就太糟糕了)

    在调用 war build 之前,让 ANT 将您的 Jetty 6 或 7 WEB-INF/jetty-web.xml 文件复制到您的 war basedir 中,然后调用类似:

    <target name="buildwar">
            <buildnumber />
        <war basedir="dist/web" destfile="${warName}-jetty${jettyVersion}.war"
         webxml="dist/WEB-INF/web.xml">         
            <webinf dir="dist/WEB-INF/">
                <include name="**/*.jar" />
            </webinf>
            <manifest>
                <attribute name="displayName" value="${warDisplayName} for Jetty ${jettyVersion}" />
                <attribute name="Implementation-Version" value="${build.number}" />            
            </manifest>         
        </war>
    </target>
    

    【讨论】:

    • 这会给我 Jetty 2 场战争,我需要 1 场。但恐怕你是对的,这是唯一的方法。我也添加了我的 Maven 方式。
    【解决方案2】:

    穷人的解决方案:为 Jetty 打造 2 场战争

    我正在考虑using maven assembly scripts to build multiple wars,但是,我需要在我的源中为这两个版本完全复制jetty-web.xml 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-24
      • 2011-05-01
      相关资源
      最近更新 更多