我怎样才能成为与Maven插件码头静态内容(7.x版)
谢谢
把你静态内容如下/yourStaticApp/src/main/webapp
任何文件夹下 - 说下/yourStaticApp/src/main/webapp/static
。当您将运行码头,这些将作为http://host:port/contextRoot/static/fileName.ext
嗯,不知道,如果可能的话。蚀码头Maven插件文档的方式配置静态源的位置,这可以归结为上述webapps
的备用位置。
...
<plugin>
...
<configuration>
<webAppSourceDirectory>${basedir}/src/staticfiles</webAppSourceDirectory>
...
</configuration>
...
</plugin>
...
由于DOC指出:
<webAppSourceDirectory> - 默认情况下,这被设置为$ {BASEDIR} / SRC /主/ web应用。如果你的静态源在不同的位置,相应地设置此参数。
参考:http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
更新:在一些研制,我发现,你其实可以从码头,Maven插件点webdefault.xml
的位置;在webdefault.xml可以配置静态内容的位置。
在您的码头Maven配置,点wendefault.xml的位置
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
...
<defaultsDescriptor>/my/path/to/webdefault.xml</defaultsDescriptor>
...
</configuration>
</plugin>
现在,在你的手webdefault.xml
你可以把这里提到的配置:http://docs.codehaus.org/display/JETTY/Static+Content - 除了包名称已经从org.mortbay.jetty...
改为org.eclipse.jetty...
见下图:
<Configure class="org.eclipse.jetty.servlet.Context">
<Set name="contextPath">/javadoc</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/javadoc/</Set>
<Call name="addServlet">
<Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
<Arg>/</Arg>
</Call>
</Configure>
参考:http://wiki.eclipse.org/Jetty/Reference/webdefault.xml
我还没有测试/使用的上方。但是,让我知道,如果你得到这个工作。或者,如果别人需要什么来完成这件事。
我有我的jetty.xml这样的配置。我也只是想更新我的问题。
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.HandlerList">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/static</Set>
<Set name="resourceBase">${static-resources-path}</Set>
<Call name="addServlet">
<Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
<Arg>/</Arg>
</Call>
</New>
</Item>
</Array>
</Set>
</New>
</Set>
这是,这对我的作品使用resourceBase和contextPath中值在JettyWebAppContext一个配置
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.7.v20170914</version>
<configuration>
<scanIntervalSeconds>60</scanIntervalSeconds>
<webApp>
<contextPath>/app</contextPath>
</webApp>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<contextPath>/images</contextPath>
<resourceBase>./../../env/localhost/config/images</resourceBase>
</contextHandler>
</contextHandlers>