I am using IntelliJ, Maven, Spring-boot.
I am trying to set the port to 8001 using VM options(3rd tab(runner), uncheck the "use project settings") as given in many answers on stack overflow. These are the 2 options I have tried.
-Dmaven.tomcat.port=8001
-Dserver.port=8001
however the tomcat server starts on the default 8080 port.
However, if I state the port on application.properties :
server.port=8001
it works fine. How can I run it using VM options. I DO NOT want to give it programmatically or configure in the application.properties.
I have already tried : Spring Boot - how to configure port
and a few others.
Please note that I run using the debug/run buttons given on intelliJ
Console shows the command as :
/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:56655,suspend=y,server=n -Dmaven.multiModuleProjectDirectory=/Users/barora/gitHub/microservice/currency-exchange-service -Dserver.port=8001 "-Dmaven.home=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3" "-Dclassworlds.conf=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf" -javaagent:/Users/barora/Library/Caches/IntelliJIdea2017.3/captureAgent/debugger-agent.jar=/private/var/folders/g5/6nfrnqnj2tz_z0q8h9ckhbqjwmtnv2/T/capture127.props -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.3.4 spring-boot:run
Where you can see -Dserver.port=8001
However it starts on 8080 :
2018-03-23 00:10:09.092 INFO 48261 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)