Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy .war file with fixed path in Tomcat?

Tags:

java

maven

tomcat

My .war file is created with a version in it. For example: myproject-1.0.0-SNAPSHOT.war

For next version it would be second version : myproject-2.0.0-SNAPSHOT.war

and so on.

Now if I deploy to tomcat the path would change with every new version as Tomcat just takes the filename as the context path.

Of course this is not acceptable as the path should be fixed.

So I already tried to create a context.xml file in META-INF folder and set path there , but did not help.

What else could I do ?

like image 494
Toni26 Avatar asked Dec 18 '25 20:12

Toni26


1 Answers

You can include a context version in your war's file name by using "##" as delimiter, see https://tomcat.apache.org/tomcat-9.0-doc/config/context.html#Naming

It will be stripped on deployment, leaving you with the same context path as before.

like image 190
f_puras Avatar answered Dec 20 '25 10:12

f_puras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!