Spring boot - Deploy war Application in Tomcat Root

236 Views Asked by At

I'm implementing a Spring boot application and i have have this requirements:

1 - The generated application must be a war
2 - Deployed as a war in the tomcat root
3 - we don't have to configure anything in tomcat

we are using spring boot 2 and tomcat 9

in our development envrionment we can start the application by the main and as default the spring boot strat it in the root context root \ as requested, this is the standard behaviour of spring boot

instead when we deploy the application in tomcat we are not able to let it start as root.
We know already the work around like renaming the final war ROOT.war, that the application will overwrite the dafault root application in tomcat that has use the \ context root, but this is not an elegant solution, we would like to understand what is the problem

By default if you doplay a spring boot application like a war in tomcat it use the war name as context root : i mean for exampl text.war then the context root will be \test
but if we try to modify the property server.servlet.context-path whatever we put in it
it could be the empty context root that we would like to achieve server.servlet.context-path=\
or another name that doenst mathch with the war name (liek server.servlet.context-path=\test2 ) the application is not properly published in tomcat (404 resource not available)
clearly if instead the war name and the configured server.servlet.context-path match all working properly

we know also the we can configure the server.xml and force the application to use the context root that we want:

The point that we are not able to understand is 1 - why when we deploy the war in tomcat we cannot configured the server.servlet.context-path becouse if the path configured doesn't match with the war name the app is to reachable 2 - sameone foud a decent solution to automatically deploy the app as context root

0

There are 0 best solutions below