Spring Boot / Gradle / Tomcat sets context path to something other than .war name

I am using Spring Boot and Gradle to create a war.

war {
    baseName = 'foo'
    version =  '0.1.0'
}

      

Since the military task has a version number, the generated military name foo-0.1.0.war

and so when deploying to Tomcat, the path to the path ishttp://localhost/foo-0.1.0/

I would like to use the ' bar ' context path , omitting the version number and using a different path.

http://localhost/bar

      

Is this possible with Spring annotation? I tried to change @RequestMapping

, but that only changes the context tohttp://localhost/foo-0.1.0/bar

Following answers here and here tried to add the xml context snippet to<catalina_home>/conf/Catalina/localhost/

<Context docBase="/foo-0.1.0" path="/bar" reloadable="true"> </Context>

      

but although Tomcat will be undeploying / foo-0.1.0, I am getting the error:

WARNING: A docBase C:\tools\apache-tomcat-7.0.53\webapps\foo-0.1.0 inside the host appBase has been specified, and will be ignored.

      

Am I setting the context incorrectly?

If setting up the context is the right solution, how do I add it to my project, since when the application loads, the Spring boot appears to generate the web-inf folder?

I tried adding context.xml

in /src/main/webapp/META-INF

, and although it is included in the war it does not change the context path

enter image description here

+3


source to share


1 answer


The root cause of the issue was using the Manger GUI to deploy the application, it seems that using the "WAR file to deploy" "tool" is using the military name even though the context is provided

Manager - war file to deploy



Using Gradle Cargo Plugin I was able to deploy the application as needed using context.xml in \src\main\resources

and using context in build.gradle

cargo {
    containerId = 'tomcat7x'
    port = 80

    deployable {
        context = 'bar'
    }
...
}

      

+2


source







All Articles