首先想要使用 Run Maven 啟動需要在IDEA設置里找到plugins 在plugins窗口下面找到Browse Repositories
打開Browse Repositories
下載完會叫你重啟IDEA 重啟前別忘了應用保存重啟完別忘了配置,首先找到你們的maven安裝包apache-maven-3.5.4-bin\apache-maven-3.5.4\conf一般都會在conf里面有個setting.xml文件,可以在網上下載個Notepad++打開這個文件,打開后找到<pluginGroups>標簽在這個里面配置<pluginGroups><pluginGroup>org.mortbay.jetty</pluginGroup></pluginGroups>這段代碼
就是這樣的 退出前別忘了保存,然后打開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>
這句代碼
再就是配置maven這個地方 Command line: jetty:run -Djetty.port=8088 一定加上這條命令。
IDEA在項目上右鍵沒有出現 Run Maven 需要下載Maven Helper插件 還是在設置里找到 plugins 在plugins 窗口下面找到 Browse Repositories
下載完會重啟IDEA 重啟前別忘了應用保存。
運行項目前先在根項目包右鍵 Run Maven 里找到 clean install
就OK了。