一、在 pom.xml 中引用插件
<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>
二、在运行配置中创建 maven 启动配置,并增加 jetty:run 命令参数,如需设置端口在后面直接附加 Djetty.port=30227
jetty:run -Djetty.port=30227
附加:还可以在 Maven 的全局配置文件 Setting 的根节点下增加如下代码
<pluginGroups>
<pluginGroup>org.eclipse.jetty</pluginGroup>
</pluginGroups>
再参考第二条做一下运行配置即可,全局配置更加方便,但是无法设置 contextPath