带有Maven Jetty插件的静态内容
如何使用maven jetty插件(7.x)提供静态内容带有Maven Jetty插件的静态内容,maven,jetty,maven-jetty-plugin,Maven,Jetty,Maven Jetty Plugin,如何使用maven jetty插件(7.x)提供静态内容 谢谢把你的静态内容放在/yourStaticApp/src/main/webapp下面的任何文件夹下——比如说在/yourStaticApp/src/main/webapp/static下面。当您运行Jetty时,这些将作为http://host:port/contextRoot/static/fileName.ext 嗯,不确定,如果可能的话。Eclipse Jetty Maven插件记录了一种配置静态源位置的方法,它可以归结为上述w
谢谢把你的静态内容放在
/yourStaticApp/src/main/webapp
下面的任何文件夹下——比如说在/yourStaticApp/src/main/webapp/static
下面。当您运行Jetty时,这些将作为http://host:port/contextRoot/static/fileName.ext
嗯,不确定,如果可能的话。Eclipse Jetty Maven插件记录了一种配置静态源位置的方法,它可以归结为上述
webapps
的备用位置
...
<plugin>
...
<configuration>
<webAppSourceDirectory>${basedir}/src/staticfiles</webAppSourceDirectory>
...
</configuration>
...
</plugin>
...
现在,您可以将webdefault.xml
放在手中,将这里提到的配置放在这里:--除了包名已从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>
/javadoc
/javadoc/
我还没有测试/使用上面的软件。但是,如果你能让它工作,请告诉我。或者,如果需要其他任何东西来完成此任务。我在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>
/静止的
${静态资源路径}
org.eclipse.jetty.servlet.DefaultServlet
/
这是一个适用于我的配置,使用JettyWebAppContext上的resourceBase和contextPath值
<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>
org.eclipse.jetty
jetty maven插件
9.4.7.v20170914
60
/应用程序
/图像
../../../env/localhost/config/images
我不是这个意思。我指的是作为静态内容的目录。请检查这个。我希望与maven达成这样的解决方案。这对我没有帮助。我确信还有其他配置。但我最感兴趣的是那个页面的第二个解决方案。可以这样在pom.xml中进行配置吗
<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>