質問

How can I define the web.xml display-name via maven using the maven-war-plugin?

In maven-ear-plugin there is an configuration option displayName to set the EAR / application.xml display-name attribute.

Wrong approach? Just set it manually in web.xml?

役に立ちましたか?

解決

Much more simplier...

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.4</version>
  <configuration>
    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
  </configuration>
</plugin>

see filteringDeploymentDescriptors's documentation. This is available since 2.1 but is disabled per default.

他のヒント

You need to use Maven's web resource filtering approach. Set 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. So you could for instance use :

<display-name>${project.name} - ${project.version}</display-name>

That would be rendered as

<display-name>My Awesome Webapp - 1.0.0-SNAPSHOT</display-name>

If you use Eclipse, you'll need m2e-wtp (look at the web resource filtering screencast in the home page)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top