2016-11-11 11 views
0

mavenprojektのクラスパスにいくつかのローカル設定ファイルを追加します。 これらのファイル "config-local"は、自分のリソースディレクトリから既存のデフォルト設定ファイルを上書きします。 ディレクトリ "config-local"が存在する場合のみ、デフォルトの設定ファイルはローカル設定に置き換えられます。フォルダYが存在する場合、Mavenはクラスパス内のファイルをオーバーライドします

ビルドにリソースとしてdirを追加しようとしましたが、動作しません。config-localが存在しないとどうなるかわかりません。答えは非常に簡単でした

答えて

0

Mavenのリソースプラグインは逆の宣言順にリソースを追加します。ただ、一番上に設定-ローカルリソースを移動

<build> 
    <sourceDirectory>src/main/java</sourceDirectory> 
    <resources> 
     <!-- The resources will be placed in reversed order in the war 
      that means first entry will be added as last resource and may override other resources --> 
     <resource> 
      <!-- ATTENTION! we need the config-local declration at first cause it shall be placed as last resource in the classpath --> 
      <directory>config-local</directory> 
     </resource> 
     <resource> 
      <directory>src/main/java</directory> 
      <includes> 
       <include>**/*.xml</include> 
       <include>**/*.properties</include> 
      </includes> 
     </resource> 
     <resource> 
      <directory>src/main/resources</directory> 
     </resource> 
    </resources> 

をし、それが最後のリソースとして追加され、他のデフォルトファイルを上書きする可能性があります。 フォルダが存在しない場合、Mavenは問題なくスキップします。

関連する問題