在项目开发过程中配置tomcat端口比较常见,今天就尝试了两种不同的方式。
- 在pom.xml中做配置:
<!-- tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/CONTEXT_PATH</path>
<port>8080</port>
<charset>UTF-8</charset>
<uriEncoding>UTF-8</uriEncoding>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
</plugin>
- 在指令后面追加参数:
tomcat7:run -Dmaven.tomcat.port=5656 -Dmaven.tomcat.path=/CONTEXT_PATH
注:最后发现pom.xml中做配置的优先级会高于第二种方式!