How to modify the default port when you start the web project using the Maven tomcat:run command

  • 2020-11-20 06:20:15
  • OfStack

When using maven, modify the plug-in tomcat startup port. 1 At the beginning, I modified in the ES3en.xml configuration file, as shown below:


<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>

But such modifications don't work

Later on the Internet to find a solution method is quite useful, and very convenient

Simply add -Dmaven. tomcat. port=8081 to the tomcat:run value in the above article. The final result is


-Dmaven.tomcat.port=8081 tomcat:run

Related articles: