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

669 Views Asked by At

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?

1

There are 1 best solutions below

2
Piotr P. Karwasz On

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

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