maven jetty プラグイン (7.x) を使用して静的コンテンツを提供するにはどうすればよいですか?
ありがとう
静的コンテンツを下の任意のフォルダーの下に置きます/yourStaticApp/src/main/webapp
-たとえば、/yourStaticApp/src/main/webapp/static
. Jetty を実行すると、これらは次のように利用可能になります。http://host:port/contextRoot/static/fileName.ext
うーん、それが可能かどうかはわかりません。webapps
Eclipse Jetty Maven プラグインは、静的なソースの場所を構成する方法を文書化しています。これは、上記の別の場所に要約されます。
...
<plugin>
...
<configuration>
<webAppSourceDirectory>${basedir}/src/staticfiles</webAppSourceDirectory>
...
</configuration>
...
</plugin>
...
ドキュメントが指摘するように:
<webAppSourceDirectory> – デフォルトでは、これは ${basedir}/src/main/webapp に設定されています。静的ソースが別の場所にある場合は、それに応じてこのパラメーターを設定してください。
参照: http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
更新:webdefault.xml
さらに調査したところ、Jetty-maven プラグインで from の場所を実際に指定できることがわかりました。また、webdefault.xml では、静的コンテンツの場所を構成できます。
Jetty 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>