1. 程式人生 > >maven專案直接運用tomcat外掛執行

maven專案直接運用tomcat外掛執行

1.在要執行的maven專案的pom.xml檔案中引入tomcat外掛

<build>
    <!-- 配置外掛 -->
    <plugins><!-- 外掛列表 -->
        <plugin><!-- 外掛 -->
	    <!-- tomcat外掛 -->
	    <groupId>org.apache.tomcat.maven</groupId>
	    <artifactId>tomcat7-maven-plugin</artifactId>
	    <configuration>
	        <port>8080</port><!-- 配置外掛訪問的埠 -->
	        <path>/</path><!-- 配置專案訪問路徑:/根目錄訪問(不需要專案名) -->
	    </configuration>
	</plugin>
    </plugins>
</build>

2.滑鼠右擊maven專案>Ran As>maven build


在Goals欄根據自己引入的tomcat版本寫上clean tomcatX:run 表示:清理後啟動tomcat (tomcat6可以直接寫成:clean tomcat:run)

注意:在啟啟動時會出現錯誤,根據錯誤提示解決就好

最後,貼出執行成功的日誌