Alternate port for Tomcat (not 8080) when starting with Maven?
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.
I had a similar problem when I had several small servlets that run their integration-test phase at the same time, which became a problem as those were configured to use the same port. But thanks to the build-helper-maven-plugin:reserve-network-port goal, it is possible to get random port numbers that are available. Then I can create an URL containing http://localhost:[port]/[servletname], which is feed into the Java test class.
There is best and easy way to change Tomcat (not 8080) when starting with Maven
Just Edit your application.properties(if you have no application.properties file, then create an application.properties file in resources directory of your maven project) file and set below line server.port=8181 //You can choose your port number.
Using just port was not working since that is not a property that you can set in <configuration>. We need to understand what is causing the problem. In my case, error was that port 8080 is taken. I changed the port in server.xml to 8081 but maven does not take it from there. We need to specifically tell it in configuration field. This is where <maven.tomcat.port>8081</maven.tomcat.port> comes in rescue. Note: You can chnage the port 8081 to something else you like.
I know it's a very old question which not have answer yet.
And I've got the similar question when I need to convert a old project which use outer tomcat to embedded tomcat use tomcat7-maven-plugin.
And what I need is build an executable jar.
But existing answer cannot work for me...
whatever i run java -jar project-name.jar after mvn package. it's always running on port 8080 which is not i wanted...
Then I search the doc Executable War
and what i fixed is just add a param in command