如何在maven中使用不同的配置捆绑战争

时间:2015-08-07 10:06:09

标签: java spring maven

  1. 我需要更改多个xml文件,同时使用maven(如下例
  2. )构建战争
  3. 我可以在目标文件夹中进行必要的更改。但它没有复制到war文件

    <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <version>1.5.3</version>
        <executions>
            <execution>
                <phase>prepare-package</phase>
                <goals>
                    <goal>replace</goal>
                </goals>
                <id>dse xml replacer</id>
                <configuration>
                <file>
                    ${project.artifactId}/target/${project.artifactId}-${version}/WEB-INF/example.xml
                </file>
                <replacements>
                    <replacement>
                        <token>reloadingEnabled=".*"</token>
                        <value>reloadingEnabled="false"</value>
                    </replacement>
                </replacements>
            </configuration>
        </execution>
    </plugin>
    

1 个答案:

答案 0 :(得分:0)

尝试 maven-war-plugin ,例如:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <webResources>
        <resource>
          <!-- this is relative to the pom.xml directory -->
          <directory>resource2</directory>
          <includes>
            <include>**/*.xml</include>
          </includes>
        </resource>
      </webResources>
    </configuration>
  </plugin>

更多信息https://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html