我必须读取多个maven项目共享的属性,为此,我尝试使用属性maven插件,如:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<configuration>
<files>
<file>conf.properties</file>
</files>
</configuration>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<url>${nexusurl}</url>
</snapshotRepository>
</distributionManagement>
</project>
文件conf.properties包含:
nexusurl=http://localhost:8081/nexus/content/repositories/snapshots
问题是,当使用mvn-deploy时,属性nexurel没有得到解决,导致的错误跟踪是:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default- deploy) on project parent: Failed to deploy artifacts/metadata: No connector
available to access repository snapshots (${nexusurl}) of type default using the
available factories WagonRepositoryConnectorFactory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on
project parent: Failed to deploy artifacts/metadata: No connector available to
access repository snapshots (${nexusurl}) of type default using the available
factories WagonRepositoryConnectorFactory
我曾试图更改插件的执行阶段(验证、安装、部署),将插件的版本更改为1.0-alpha-2,但问题仍然存在。
我将感谢任何援助。谢谢,
问题是pom.xml的读取和属性集成要早于插件加载。您可以将插件用于构建中的值,例如插件之间的值,但您试图做的事情不会像那样工作。