Put together a very basic Spring Boot RESTful backend with some CRUD endpoints. Trying to start it up on my Centos7 server. However I already have an application listening on its default port, 8080, so I have to configure that.
I have tried:
java -jar target/rest-1.0-SNAPSHOT.jar --server.port=8090
java -jar target/rest-1.0-SNAPSHOT.jar --Dserver.port=8090
java -jar target/rest-1.0-SNAPSHOT.jar --port=8090
java -jar target/rest-1.0-SNAPSHOT.jar --Dport=8090
My application.properties contains the line:
server.port=${port:8090}
Spring Boot still starts up the embedded Tomcat container on port 8080. It's not getting the message. What am I missing?
Edit: setting SERVER_PORT=8090
was effective - see below
Try with -Dserver.port=8090
note single -
or server.port=xxxx
in application.properties file
EDIT:-
Check your log, below line will echo in console 2015-10-16 23:13:23.082 INFO 4228 --- [ main] sbcetTomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8090 (http)
VM arg overrides application.properties
If you have a "application.yml" or "application.properties" in the same folder of jar, the jar will take preference of the external configuration file. Doesnt make sense for me, but its true. The springboot has higher priority to external configuration file instead the internal one.
We have four different ways to change default port.
For more details, visit below http://www.javainterviewpoint.com/spring-boot-change-embedded-tomcat-default-port/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.