我有一个关于maven properties插件的问题。我的问题与How to read an external properties file in Maven有些关系
按照那篇文章的建议,我已经设法让它完成了我想让它做的大部分事情。我的配置如下所示:
<dependency>
<groupId>org.kuali.maven.plugins</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.8</version>
</dependency>
...
<plugin>
<groupId>org.kuali.maven.plugins</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/${environment}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>现在,我遇到的问题如下:我已经配置了一个简单的存储库来存储内容,如下所示:
<distributionManagement>
<repository>
<id>localRep</id>
<url>file:${localRepositoryLocation}</url>
</repository>
</distributionManagement>运行mvn deploy时,不会替换${localRepositoryLocation}。
[INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) @ SomeApp ---
Uploading: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.war
Uploaded: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.war (5754 KB at 18322.3 KB/sec)
Uploading: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.pom
Uploaded: file:${localRepositoryLocation}/SomeApp/SomeApp/1.0.0/SomeApp-1.0.0.pom (7 KB at 2051.1 KB/sec)另外,我应该注意到,我在mojo版本中也使用了这个插件,它产生了完全相同的行为。因此,如果来自两个不同提供商的相同插件有相同的结果,那么一定是我做错了什么。
有人能帮上忙吗?
致以亲切的问候,安德烈
发布于 2012-06-12 00:04:02
首先,这两个插件是不同的。原始文件在<version>1.0-alpha-2</version>中可用,而目标文件的配置需要codehaus plugin属性:
<configuration>
<files>
<file>etc/config/dev.properties</file>
</files>
</configuration>kuali-plugin在<version>1.1.10</version>中可用,并且是与原始插件相比的扩展版本,配置需要location属性:
<configuration>
<locations>
<location>classpath:META-INF/spring/database.properties</location>
</locations>
</configuration>在这里你可以看到改进,引用插件代码:
可以找到属性文件的位置。任何url Spring资源加载都可以理解是有效的。例如classpath:myprops.properties__。同时支持.properties和.xml样式属性。
代码中的问题是示例(来自codehaus文档)是错误的。正确的配置如下所示:
<plugin>
<groupId>org.kuali.maven.plugins</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.1.10</version>
<configuration>
<locations>
<location>classpath:META-INF/spring/database.properties</location>
</locations>
</configuration>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>如您所见,配置标记不在执行标记下。
https://stackoverflow.com/questions/9804860
复制相似问题