I'm currently trying to get a Spring Boot application up and running with some small configuration changes, but I can't seem to get the port to listen correctly. It seems that the server.xml that the tomcat instance loads overwrites anything my application.properties file specifies.
application.properties:
logging.level.app = TRACE
logging.file = /tmp/my-server.log
server.port = 8081
When I deploy this to my /usr/local/tomcat/webapps, I can access the server, but only on port 8080. It seems to ignore the server.port property. I believe that the server is picking up the properties file correctly since the logging correctly goes to /tmp/my-server.log
The end goal is to have the server listen on the port of my choice when running in Amazon Elastic Beanstalk. I can update the ports on the load balancer, but if the server will only listen on it's pre-configured port, that won't matter.
Thanks ahead of time for any help!
OSX Yosemite, Tomcat 8.0.24, Spring Boot v1.2.4
Spring Boot properties like server.port
will only take effect if you use the embedded Tomcat. That is, if you start your application by executing your main
method with SpringApplication.run()
in it or by creating an executable JAR and starting it with java -jar
.
When you deploy your application as a WAR archive into a stand-alone Tomcat, you have to configure Tomcat in the traditional way by editing server.xml
and possibly other configuration files.
server.port property is meant to be used only with an embedded application server. If you want to use a standalone one, then the configuration needs to be done on application server itself. In case of tomcat, if is specified in server.xml file.
If you want to run the application on AWS Elastic Beanstalk, when you are creating the environment you can specify that you want to have an webserver + tomcat.
This way you won't need to worry about ports. Amazon will handle it for you.
It is possible to edit the port in the configuration file:
{Tomcat installation folder}\conf\server.xml
<!-- Define a non-SSL HTTP/1.1 Connector on port 8180 -->
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
or
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8181" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With