1、安裝插件jetty,完成後重啓idea
2、找到maven安裝包F:\Program Files\Maven\apache-maven-3.6.1\conf(注意,此處的路徑是mave安裝的路徑,具體每個人可能不一樣)。在conf裏面有個setting.xml文件,打開後找到<pluginGroups>標籤在這個裏面配置<pluginGroup>org.mortbay.jetty</pluginGroup>這段代碼
3、在idea項目的pom.xml裏找到<plugins>標籤下配置
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webApp>
<contextPath>/</contextPath>
</webApp>
<stopKey>webx</stopKey>
<stopPort>9999</stopPort>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8088</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<requestLog implementation="org.eclipse.jetty.server.NCSARequestLog">
<filename>target/access.log</filename>
<retainDays>90</retainDays>
<append>false</append>
<extended>false</extended>
<logTimeZone>GMT+8:00</logTimeZone>
</requestLog>
<systemProperties>
<systemProperty>
<name>productionMode</name>
<value>${productionMode}</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
此處注意:我在粘貼這段代碼,並且執行“Import Changes”
後,有提示錯誤如下,直接根據idea的提示處理即可
4、配置Maven(配置maven這個地方 Command line: jetty:run -Djetty.port=8088 一定加上這條命令)
5、IDEA在項目上右鍵沒有出現 Run Maven 需要下載Maven Helper插件(完成後重啓IDEA)
6、運行項目前先在根項目包右鍵 Run Maven 裏找到 clean install
之後,就OK了。