1

I'd like to include some Maven properties(*) in src/main/webapp/META-INF/context.xml.

(*) E.g. ${data-source-name}, ${data-source-factory}, ${jdbc-connection-url} etc. - but in the words of the late, great Leslie Nielsen, that's not important right now.

Thought this might be achievable using something like the following maven-resource-plugin config:

<build>
  <resources>
    <resource>
      <directory>src/main/webapp</directory>
      <includes>
        <include>**/*</include>
      </includes>
      <filtering>true</filtering>
    </resource>
  </resources>
</build>

But this results in two versions of context.xml in the WAR file:

\META-INF\context.xml                 <=== Properties *not* expanded
\WEB-INF\classes\META-INF\context.xml <=== Properties expanded

Where am I going wrong?

4

1 回答 1

3

经过一番谷歌搜索后,我发现了如何使用 maven-war-plugin 而不是 maven-resources-plugin:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <configuration>
        <webResources>
          <resource>
            <directory>src/main/webapp</directory>
            <filtering>true</filtering>
          </resource>
        </webResources>
      </configuration>
    </plugin>
  </plugins>
</build>
于 2014-10-27T15:01:10.297 回答