.propertiesファイルは、子プロジェクトに親プロジェクトからファイルをどのように共有します

qleoz12:

私は、.propertiesファイルに親プロジェクトを持っているこのファイルは、プロジェクトの上に定義されたプロファイルに基づいてフィルタリングされ、このプロジェクトは子プロジェクトまたはモジュールを持って、私は、フィルタリング.propertiesファイルをご希望の子プロジェクトのために使用する利用可能だったと私缶Javaまたは何でresourceBoundleを使用して、ファイルのアクセスプロパティ。

イムは、使用するために運を試してみませんどのようにMaven2をモジュール間のフィルタファイルを共有するには?- > MojoHausプロジェクト

親ポンポン

<?xml version="1.0" encoding="UTF-8"?>
<project 
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.data</groupId>
    <artifactId>data2</artifactId>
    <version>data-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>dataNameapp</name>

    <modules>
        <module>child  1</module>
        <module>child  2</module>
        </modules>
.....
</project>

子プロジェクト

reference parent properties in pom some code In guess

Javaコード上で使用して
child1の/ test.java

ResourceBundle resourceBundleProperties= ResourceBundle.getBundle("parentproperties")

更新

マイル親プロジェクトではエキストラでこのファイルを濾過し、私はそれを渡すとき、私はそれが他の内部ファイルのプロパティを更新したいと思います

parent--extras/filtered.properties (file filtered)
   child
   --filters/filtered.properties (get from parent)  
   --resources/final.properties  (filtered of filtered.properties)
madhead:

あなたはするプラグインMavenのリソースを試すことができますコピーのように、親プロジェクトからファイルを:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
              <execution>
                <id>copy-resources</id>
                <phase>process-resourcesphase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${basedir}/target/resources</outputDirectory>
                  <resources>          
                    <resource>
                      <directory>${project.parent.basedir}/src/resources/extras</directory>
                      <filtering>true</filtering>
                    </resource>
                  </resources>              
                </configuration>            
              </execution>
            </executions>
          </plugin>
        </plugins>
        ...
      </build>
      ...
    </project>

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=235668&siteId=1