You need to use the Maven web resource filtering approach. Define the following configuration in your maven-war plugin:
<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.2</version> <configuration> <webResources> <resource> <directory>src/main/webapp/WEB-INF/</directory> <targetPath>WEB-INF</targetPath> <includes><include>web.xml</include></includes> <filtering>true</filtering> </resource> </webResources> </configuration> </plugin>
And in your web.xml you can use any properties defined in your pom.xml. For example, you can use:
<display-name>${project.name} - ${project.version}</display-name>
This will display as
<display-name>My Awesome Webapp - 1.0.0-SNAPSHOT</display-name>
If you use Eclipse, you will need m2e-wtp (look at the screencast for filtering web resources on the home page)
source share