1、在 pom.xml 中引用插件web
<plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.16.v20170120</version> <configuration> <webAppConfig> <contextPath>/gateway/</contextPath> <defaultsDescriptor></defaultsDescriptor> </webAppConfig> </configuration> </plugin>
2、在运行配置中建立 maven 启动配置,并增长 jetty:run 命令参数,如需设置端口在后面直接附加 Djetty.port=30227eclipse
jetty:run -Djetty.port=30227
附加:还能够在 Maven 的全局配置文件 Setting 的根节点下增长以下代码maven
<pluginGroups> <pluginGroup>org.eclipse.jetty</pluginGroup> </pluginGroups>
再参考第二条作一下运行配置便可,全局配置更加方便,可是没法设置 contextPathspa