Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have version in WAR filename, but not require it in the URL when deployed in Tomcat

I want to version my WAR to make DevOps lives easier, i.e.: foo-3.2.0.war. In pom.xml, I have:

<build>
  <finalName>foo</finalName>

but also

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>${maven-war-plugin.version}</version>
  <configuration>
    <warName>${project.artifactId}-${project.version}</warName>

that imparts the current version in pom.xml to the WAR filename. So far, so good.

The problem becomes that the version is required in the URL when deployed to Tomcat. I want my application accessed thus: http://hostname:port/foo and not http://hostname:port/foo-3.2.0 (etc.) because I'd have to annoy my consumer with the version change.

Is it possible to work around this problem without just going back to an unversioned WAR file?

like image 605
Russ Bateman Avatar asked Sep 10 '25 15:09

Russ Bateman


1 Answers

You can use ${project.artifactId}##${project.version} as naming scheme.

The part after ## will not be part of the context name (cf. parallel deployment).

like image 158
Piotr P. Karwasz Avatar answered Sep 13 '25 07:09

Piotr P. Karwasz