這是一個很好的答案喬。謝謝。我一直在尋找它。
我只是舉了一個例子,其中我和Nathan有同樣的問題。
我使用Maven企業存儲庫(Nexus或Artifactory),我位於代理之後,這意味着我不能從我的任何其他存儲庫直接下載(並且不想)。
Jasper的報告net.sf.jasperreports:jasperreports:6.2.0在它的pom中定義了一些存儲庫。
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.2.0</version>
...
<repositories>
<repository>
<id>jasperreports</id>
<url>http://jasperreports.sourceforge.net/maven2</url>
</repository>
<repository>
<id>jaspersoft-third-party</id>
<url>http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/</url>
</repository>
</repositories>
這會導致以下情況例外:
C:\my-project>mvn verify
[INFO] Scanning for projects...
[INFO] Building my-project 1.0.0-SNAPSHOT
[INFO]
Downloading: http://mynexus/nexus/content/groups/ch-public/com/lowagie/itext/2.1.7.js4/itext-2.1.7.js4.pom
Downloading: http://jasperreports.sourceforge.net/maven2/com/lowagie/itext/2.1.7.js4/itext-2.1.7.js4.pom
Downloading: http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js4/itext-2.1.7.js4.pom
[INFO] BUILD FAILURE
[INFO] Could not resolve dependencies for project ... :
Failed to collect dependencies at net.sf.jasperreports:jasperreports:jar:6.2.0 ->
com.lowagie:itext:jar:2.1.7.js4: Failed to read artifact descriptor for com.lowagie:itext:jar:2.1.7.js4:
Could not transfer artifact com.lowagie:itext:pom:2.1.7.js4
from/to jasperreports (http://jasperreports.sourceforge.net/maven2):
Connect to jasperreports.sourceforge.net:80 [jasperreports.sourceforge.net/216.34.181.96]
failed: Connection timed out:
如由Joe描述的解決方案是: 在全球的settings.xml(C:/maven-installation/conf/settings.xml)或私人settings.xml中(〜/ .m2目錄/ settings.xml中),添加以下文件:
<profiles>
<profile>
<id>ignore-repositories</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<repositories>
<repository>
<id>jasperreports</id>
<url>http://mynexus/nexus/content/groups/ch-public/
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jaspersoft-third-party</id>
<url>http://mynexus/nexus/content/groups/ch-public/
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
重要:在配置文件的存儲庫id(碧玉報告,jaspersoft第三方)完全匹配在pom.xml中使用的存儲庫的ID - 在這種情況下,net.sf.jasperreports的pom.xml:jasperreports:6.2.0
不要忘記添加將「外部」存儲庫添加到Maven Enterprise Repository的「代理」列表中
感謝您的解決方法和鏈接! –