我试图在我的包中引入属性文件(基于Spring Dynamic Modules的OSGI)。我希望在该属性文件中保留数据库URL,用户名,密码等属性,并希望maven从该文件中读取。
我试图在我的pom中引入过滤:
<properties>
<database.username>${development_user}</database.username>
</properties>
<build>
<filters>
<filter>src/main/resources/Application_${env}.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>bundle</id>
<phase>package</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<executions>
<execution>
<id>bundle</id>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>*/pom.</excludes>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
我的Application_local.properties文件中有以下属性:
development_user=dev_user
但是当我使用命令“mvn clean install -Denv = local”构建bundle时,系统会在我的database.xml中插入'$ {development_user}'作为值
有人可以帮我解决这个问题吗?
答案 0 :(得分:1)
试试这个 -
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<id>read</id>
<phase>validate</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/main/resources/Application_${env}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>