在maven的web專案中內嵌tomcat外掛執行war包
阿新 • • 發佈:2019-02-09
0、環境要求
- Unix System\windwos\macOS
- JDK 1.7+
- Maven 3.0 or later
- 我測試的編譯環境是:
- macOS10.11.6和windows10
- jdk1.8/jdk1.7
- Maven 3.3.9
- 我的本機開發環境:
- MacOS 10.11.6
- eclipse Mars.2
1、在pom中配置tomcat-maven-plugin
<project> ... <packaging>war</packaging> ... <build> ... <plugins> ... <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat6-maven-plugin</artifactId> <version>2.2</version> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> </plugin> ... </plugins> ... </build> ... </project>
2、執行war包
執行 tomcat7:run-war或者tomca6:run-war如果想要修改其他配置可以在
<plugin>標籤下新增如下等配置 <configuration> <port>8080</port> <path>/demo</path> <uriEncoding>UTF-8</uriEncoding> <finalName>demo</finalName> <server>tomcat7</server> </configuration>
參考:http://tomcat.apache.org/maven-plugin-2.2/