我不得不读财产多Maven项目共享,为此,我尝试使用属性 - 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部署时,该属性nexusurl没有解决,错误跟踪结果是:
[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,但问题依然存在。
我会感谢任何援助。 谢谢,
你的conf.properties似乎被忽略。你如何参考?如果你运行'mvn deploy -Dnexusurl = http:// localhost:8081/nexus/content/repositories/snapshots'会发生什么? – MrsTang
不,属性文件不会被忽略,问题是用carlspring的回答描述的问题,部分中的值在最初加载POM时分配。 properties-maven-plugin只影响加载属性之后的插件执行。 –