2011-12-05 8 views
6

私はいくつかの可変プロパティの値を持ち、Mavenプロファイルを使って正しい出力にしようとしています。私は私の休止状態のXML、log4j.propertiesのためにこれをしていないし、問題がありません。maven変数プロパティのフィルタリング

私のプロジェクト#1では、/ src/main/resourcesの下にたくさんのファイルがあります。そして、次のようにmavenのプロパティとリソースフィルタリングを設定します。

<properties> 
    <log.level>DEBUG</log.level> 
</properties> 


<profiles> 
    <profile> 
     <id>production</id> 
     <properties> 
    <log.level>INFO</log.level> 
     </properties> 
    </profile> 
</profiles> 

<build> 
    <resources> 
     <resource> 
      <directory>src/main/resources</directory> 
      <filtering>true</filtering> 
     </resource> 
    </resources> 
</build> 

上記は問題なく動作しました。 しかし、私のプロジェクト#2では、いくつかのファイルに変数のプロパティがありますが、/ src/main/webapp/WEB-INFの下にあります。上記と同じですが、WEB- INFと動作しません。/src/main/resourcesの下にファイルを置くためにプロジェクト#2を試してみました。

/src/main/webapp/WEB-INFの下にファイルがあるとリソースフィルタリングに問題があるようですが、戦争が発生したときにWEB-INFフォルダに移動するようにファイルが必要です。

これを行う方法については、誰かがポインタを持っていますか?

は、ここで私もこの問題を抱えていた仕事をdoesntののpom.xml(リソースフィルタリングが完全に無視されます)

<properties> 
     <wsdl.url>http://stage/wsdl-url</wsdl.url> 
</properties> 

<profiles> 
    <profile> 
     <id>production</id> 
     <properties> 
    <wsdl.url>http://prod/wsdl-url</wsdl.url> 
     </properties> 
    </profile> 
</profiles> 

<build> 
    <resources> 
     <resource> 
      <directory>src/main/webapp/WEB-INF</directory> 
      <filtering>true</filtering> 
     </resource> 
    </resources> 
</build> 

答えて

5

から次snipetです。 - 私は必要なものだけ

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <configuration> 
     <filters> 
      <filter>filter.properties</filter> 
     </filters> 
     <webResources> 
      <resource> 
       <directory>WebContent/WEB-INF</directory> 
       <filtering>true</filtering> 
       <targetPath>WEB-INF</targetPath> 
      </resource> 
     </webResources> 
    </configuration> 
</plugin> 
+0

ありがとう:私はPOMのメイン<resources>セクションは戦争プラグインによって無視される疑いがある、それゆえ私は直接プラグインの設定を作ってみました –

関連する問題