我有以下Maven代码片段
<plugin>
<!-- http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin -->
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.16</version>
<configuration>
<contextPath>/thomas</contextPath>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
</configuration>
</plugin>
我想将上下文路径设置为"/",但Jetty插件不尊重它,上下文退回到使用文件夹(或模块)名称作为上下文路径。如果我用名称设置上下文路径,例如:
<contextPath>/thomas</contextPath>
有什么建议吗?
这就是你需要的jetty 8
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.7.v20120910</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
</webApp>
</configuration>
</plugin>
这适用于我与Jetty 6(版本8和9见答案从Michael McCallum):
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.22</version>
<configuration>
<contextPath>/</contextPath>
</configuration>
...
</plugin>
希望有帮助。
(通常我在提供赏金后才让它工作!!)
真正有效(当前版本示例):
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.0.M2</version>
<configuration>
<webApp>
<contextPath>/${path}</contextPath>
</webApp>
</configuration>
</plugin>
成功了!看这个:
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<contextPath>/</contextPath>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/yourContextPath</contextPath>
</webApp>
</configuration>
</plugin>