今天想試試除了tomcat之外的另一個服務器jetty的使用;
關於項目在tomcat中的啟動大概有多種,尤其是在本地環境下,ide關於tomcat的優化做的很好,但是在idea上面部署tomcat總不能正確的部署war包;
會提示錯誤404 not found,此時jetty確實可以正常的跑起來的;
雖然它只是一個war包部署到jetty里面就可以正常的運行,但是網上的資料很難找,或者干脆就是下面的通過mvn配置的;遂放棄;
同時也感覺是不是配置的情況出了問題,eclipse的產品,對idea的支持有點不友好;

除此之外,還可以通過自己寫一個main方法實現jetty的啟動,但是我覺得太過復雜,就放棄了;
綜合考慮,可以通過maven的plugin配置一下啟動;
比較簡單,主要是可以很快的找到資源;
首先,要找到jar包的坐標:
我的方法是通過maven reposity 搜索;

在pom文件中添加如下配置:
<build>
<finalName>SmartTalent</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
<server>tomcat7</server>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.5.v20170502</version>
<configuration>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<!-- web項目根路徑 -->
<contextPath>/</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
通過引入包,通過配置簡單的mvn命令即可正確的實現服務器的啟動;
通過點擊 edit configurations-> +號 ->maven->

點擊ok即可正常的啟動;
