1.安装maven helper插件,略
2.项目pom.xml文件中添加jetty插件配置
<build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.4.12.v20180830</version> <configuration> <httpConnector> <!--指定端口号--> <port>8080</port> <idleTimeout>10000</idleTimeout> </httpConnector> <webApp> <contextPath>/${project.artifactId}</contextPath> </webApp> </configuration> </plugin> </plugins> </build>
3.run-->edit configurations,新增maven
a)在working directory 内,选择项目路径
b)在command line内,输入jetty:run
c) 取消test
d) run 或debug启动项目,即可
参考文档:https://www.cnblogs.com/lixyu/p/10001894.html