Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternate port for Tomcat (not 8080) when starting with Maven?

Tags:

maven-2

tomcat

Is there an easy way to specify an alternate port for Tomcat in the pom or on the commandline. I'd like to have several projects running on the same machine.

like image 251
sammyo Avatar asked Mar 14 '09 20:03

sammyo


2 Answers

I know this thread is old but…

The link to the documentation, provided by Greg is interesting :

port:
The port to run the Tomcat server on.
    Type: int
    Required: No
    Expression: ${maven.tomcat.port}
    Default: 8080

The expression is what maven use to get the value in its code. It could come from a configuration file, or from the command line.

You could run

mvn -Dmaven.tomcat.port=8181 tomcat:run-war
like image 132
Vincent Demeester Avatar answered Nov 18 '22 02:11

Vincent Demeester


Using the syntax given on tomcat-maven-plugin, you can directly specify the port:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>            
  <configuration>          
    <server>tomcat-development-server</server>
    <port>9966</port>
  </configuration>
</plugin>
like image 32
Greg Avatar answered Nov 18 '22 01:11

Greg