我不得不讀財產多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隻影響加載屬性之後的插件執行。 –