使用Maven tomcat:run命令启动web项目时修改默认端口的方法

在使用maven时,修改插件tomcat启动端口。一开始我在pom.xml配置文件里面修改,如下面所示:

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
  <port>9999</port> 
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>

可是这样的修改方法 并不起作用

后来在网上查找发现一种解法方法是挺管用的,而且很方便

直接在上述文章中的Goals值中的tomcat:run前边加上-Dmaven.tomcat.port=8081即可,最终效果为

-Dmaven.tomcat.port=8081 tomcat:run

以上这篇使用Maven tomcat:run命令启动web项目时修改默认端口的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持来客网。