title: Spring boot application not honoring VM options for server port
body: <p>I am using IntelliJ, Maven, Spring-boot.</p>
  
  <p>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.</p>
  
  <pre><code>-Dmaven.tomcat.port=8001
  -Dserver.port=8001
  </code></pre>
  
  <p>however the tomcat server starts on the default 8080 port.</p>
  
  <p>However, if I state the port on application.properties : </p>
  
  <pre><code>server.port=8001
  </code></pre>
  
  <p>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. </p>
  
  <p>I have already tried :
  <a href="https://stackoverflow.com/questions/21083170/spring-boot-how-to-configure-port/30249389#30249389">Spring Boot - how to configure port</a></p>
  
  <p>and a few others.</p>
  
  <p>Please note that I run using the debug/run buttons given on intelliJ </p>
  
  <p><a href="https://i.stack.imgur.com/DTRZ7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DTRZ7.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/g5FGU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g5FGU.png" alt="enter image description here"></a></p>
  
  <p>Console shows the command as :</p>
  
  <pre><code>/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
  </code></pre>
  
  <p>Where you can see <code>-Dserver.port=8001</code></p>
  
  <p>However it starts on 8080 :</p>
  
  <pre><code>2018-03-23 00:10:09.092  INFO 48261 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
  </code></pre>