Is there a standard way to configure the deployment path in Spring Boot?

I am exploring the possibilities of Spring Boot right now, and I'm in a little dead end. I want to be able to run two Spring boot applications at once, both on one server and on different paths (it is deployed once to / , the other to /another-path ).

Since this is a built-in instance of Tomcat running in Spring Boot, the configuration files cannot be changed for me.

Is there a standard way to do this? Is it possible?

+6
source share
2 answers

Spring Boot comes with some pre-installed property support. If you create an application.properties file, you can include:

 server.port=<another port> server.address=<another IP address> server.sessionTimeout=<another timeout setting> server.contextPath=/your-other-path 

This can be in application.properties next to your executable JAR embedded in the JAR file, or simply applied as -Dserver.contextPath = / your-alt-path with the java command. They cascade, that is, you can insert one set of default values ​​into the JAR, override using the local application.properties file, and then finally override application.properties using the -D options.

+20
source

Since it uses the built-in tomcat, you should be able to add /META-INF/context.xml for each application that indicates the path (at least this should work for a normal cat).

This works for our regular tomcat inline stuff, so I expect it to work for Spring Boot as well.

+1
source

Source: https://habr.com/ru/post/953743/


All Articles