Java 使用maven插件配置Jetty(目标运行分叉)覆盖ResourceBase

Java 使用maven插件配置Jetty(目标运行分叉)覆盖ResourceBase,java,maven,jetty,maven-jetty-plugin,Java,Maven,Jetty,Maven Jetty Plugin,我正试图通过maven插件执行Jetty(9.2.4.v20141103),它有多个资源库。我已经调试了de代码,似乎QuickConfiguration类用以下代码覆盖了已配置的ResourceBase: public void preConfigure(WebAppContext context) throws Exception { String war = context.getWar(); if ((war == null) || (war.length

我正试图通过maven插件执行Jetty(9.2.4.v20141103),它有多个资源库。我已经调试了de代码,似乎QuickConfiguration类用以下代码覆盖了已配置的ResourceBase:

  public void preConfigure(WebAppContext context)
    throws Exception
  {
    String war = context.getWar();
    if ((war == null) || (war.length() <= 0)) {
      throw new IllegalStateException("No location for webapp");
    }
    resolveTempDirectory(context);

    Resource webApp = context.newResource(war);
    if (webApp.getAlias() != null)
    {
      LOG.debug(webApp + " anti-aliased to " + webApp.getAlias(), new Object[0]);
      webApp = context.newResource(webApp.getAlias());
    }
    if ((!webApp.exists()) || (!webApp.isDirectory()) || (webApp.toString().startsWith("jar:"))) {
      throw new IllegalStateException("Webapp does not exist or is not unpacked");
    }
    context.setBaseResource(webApp);

    LOG.debug("webapp={}", new Object[] { webApp });

    Resource quickStartWebXml = getQuickStartWebXml(context);
    LOG.debug("quickStartWebXml={}", new Object[] { quickStartWebXml });

    context.getMetaData().setWebXml(quickStartWebXml);
  }
我的contextXml文件:

<Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/shop</Set>

    <!-- to avoid checking for jsp-->
    <Call name="setAttribute">
      <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
      <Arg>zzzzzzzzzzzzzzzzzzzzzzzzz</Arg>
    </Call>
    <Call name="setAttribute">
      <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
      <Arg>zzzzzzzzzzzzzzzzzzzzzzzzz</Arg>
    </Call>
    <New id="staticResources" class="org.eclipse.jetty.util.resource.ResourceCollection">
        <Arg>
            <Array type="java.lang.String">
                <Item>D:\Project\view\src\main\webapp</Item>
                <Item>D:\Project\core\web\src\main\resources\META-INF\resources</Item>
                <Item>D:\Project\modules\shop\front\src\main\resources\META-INF\resources</Item>
                <!-- More directories-->

            </Array>
        </Arg>
    </New>      

     <Set name="baseResource">
        <Ref refid="staticResources"></Ref>
     </Set>
     <!-- Database Stuff-->

/商店
org.eclipse.jetty.server.webapp.webinIncludeJarPattern
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
D:\Project\view\src\main\webapp
D:\Project\core\web\src\main\resources\META-INF\resources
D:\Project\modules\shop\front\src\main\resources\META-INF\resources
我还尝试在pom.xml中包含ResourceBase,但没有任何改变。在调试代码时,它似乎正确地加载了目录,但之后,它执行QuickConfiguration预配置方法,并用webapp目录覆盖基本资源


?有什么帮助吗?

为什么要尝试使用多个资源库?(jetty maven插件需要配置资源库本身,以从maven子系统报告的多个位置中提取内容,包括构建中使用的各种插件报告的所有位置,否则您的webapp无法启动)感谢您的回答。对不起,我不明白你的意思。我需要多个资源库,因为该项目由几个maven子项目组成,它们有自己的静态资源(如html、js和css)。它完全独立于构建过程。正如我所解释的,目标码头:跑步就像魅力。只有目标jetty:run forked(似乎使用QuickConfiguration类)覆盖了我的resourcebase配置。您正在与jetty maven插件想要完全控制的设置进行斗争。为什么不把html、js和css捆绑成标准的Servlet资源jar
WEB-INF/*.jar/改为META-INF/resources/
<Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/shop</Set>

    <!-- to avoid checking for jsp-->
    <Call name="setAttribute">
      <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
      <Arg>zzzzzzzzzzzzzzzzzzzzzzzzz</Arg>
    </Call>
    <Call name="setAttribute">
      <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
      <Arg>zzzzzzzzzzzzzzzzzzzzzzzzz</Arg>
    </Call>
    <New id="staticResources" class="org.eclipse.jetty.util.resource.ResourceCollection">
        <Arg>
            <Array type="java.lang.String">
                <Item>D:\Project\view\src\main\webapp</Item>
                <Item>D:\Project\core\web\src\main\resources\META-INF\resources</Item>
                <Item>D:\Project\modules\shop\front\src\main\resources\META-INF\resources</Item>
                <!-- More directories-->

            </Array>
        </Arg>
    </New>      

     <Set name="baseResource">
        <Ref refid="staticResources"></Ref>
     </Set>
     <!-- Database Stuff-->