Maven Jetty Plugin 下多Web应用源目录设置
配置多个Web应用源代码目录
从jetty-6.1.12.rc2 和 jetty-7.0.0pre3起是可用的
它可以通过Resource[], String[], 或者 String (csv)的方式在构造器中配置。
最初的资源(列表的首要部分)是最主要的资源。
WEB-INF/classes和WEB-INF/lib已经合并。
这基本上意味着你的webappA依赖的那些类通过地址指向后也可以webappB使用。
这个功能可重叠Web应用。
配置context.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="baseResource">
<New class="org.mortbay.resource.ResourceCollection">
<Arg>
<Array type="java.lang.String">
<Item>E:/path/to/my/main/app</Item>
<Item>/home/johndoe/path/to/my/other/source</Item>
<Item><SystemProperty name="jetty.home" default="."/>/webapps/foo</Item>
</Array>
</Arg>
</New>
</Set>
</Configure>
配置 jetty-maven-plugin
<!-- comma(or semi-colon) separated values逗号(或分号)分隔值-->
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<resources>src/main/webapp,target/foo,E:/my/other/source,/home/johndoe/path/to/my/other/source</resources>
</baseResource>
</webAppConfig>
<reload>manual</reload>
</configuration>
当maven因依赖注入过多资源而失败时,使用:
<resourcesAsCsv>src/main/webapp,target/foo,E:/my/other/source,/home/johndoe/path/to/my/other/source</resourcesAsCsv>请注意,对于其他Web应用来源,您可以将它们添加到插件的额外扫描目标从而动态加载。
示 例
方 案:
WebAppX:
/foo.jsp
/bar.jsp
/WEB-INF/web.xml
WebAppY:
/bar.jsp
/baz.jsp
/WEB-INF/web.xml
/WEB-INF/sitemesh.xml
配 置:
<resources>webappY/src/main/webapp, webappX/src/main/webapp</resources>
输 出:
当 Y(第一资源) 继承/覆盖 X, 你能获取:
/foo.jsp
/bar.jsp (Y)
/baz.jsp
/WEB-INF/web.xml (Y)
/WEB-INF/sitemesh.xml
重 叠
从jetty-6.1.12.rc3 和 jetty-7.0.0pre4起是可用的
当使用mvn jetty:run,你根本不需要配置任何东西。
只需添加一个像下面这样的依赖:
<dependency>
<groupId>org.dojotoolkit</groupId>
<artifactId>dojo-war</artifactId>
<version>1.2-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-test</artifactId>
<version>6.1.12.rc3</version>
<type>war</type>
</dependency>
如果手动配置,就像下面这样:
<resources>src/main/webapp,/home/johndoe/path/to/dojo-war/dir,/home/johndoe/path/to/jetty-test/dir</resources>
这个重叠的顺序取决于你在pom.xml如何安排war的依赖(从上到下)。
页:
[1]