我正在使用Apache Maven构建我的项目并且已经配置了一个自定义存储库但是当它到达存储库时它只会挂起很长一段时间
下载:http://maven.mycompany.com/m2/org/springframework/spring/2.5.6/spring-2.5.6.pom
几分钟后,它将从中央仓库下载并下载
正在下载:http: //repo1.maven.org/maven2/org/springframework/spring/2.5.6/spring-2.5.6.pom 12K下载(spring-2.5.6.pom)
我希望超时比这快得多.所有较新版本的maven都会发生这种情况.版本2.0.6或更早版本没有这个问题,它会更快地超时.
Ric*_*ler 21
在2.1之前的Maven版本中,没有办法将客户端配置为超时,但是如果设置更新策略,则可以将其配置为更少检查更新.这部分解决了这个问题.
例如:
<repository>
<id>myrepo</id>
<url>http://maven.mycompany.com/m2</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
Run Code Online (Sandbox Code Playgroud)
有效值为:
另一个考虑因素是您用于托管内部存储库的软件.使用Nexus等存储库管理器,您可以通过管理器管理所有外部远程存储库连接,并为这些远程连接配置超时.然后,您的客户端将仅查询存储库管理器,该管理器应尽快响应超时.
更新:
如果您知道特定存储库不会提供依赖关系,则可以将其分隔为配置文件,因此在该构建中不会引用它.
<profiles>
<profile>
<id>remote</id>
<repositories>
<repository>
<id>central</id>
<url>http://repo1.maven.org</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
...
</repositories>
</profile>
<profile>
<id>internal</id>
<repositories>
<repository>
<id>myrepo</id>
<url>http://maven.mycompany.com/m2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
...
</repositories>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
使用上面的配置,运行mvn包-Premote将不会连接到内部存储库,因此超时不会是一个因素.
您可以通过在设置中添加一些额外的配置来避免在每个构建中指定配置文件:
<settings>
...
<activeProfiles>
<activeProfile>internal</activeProfile>
<activeProfile>remote</activeProfile>
</activeProfiles>
...
</settings>
Run Code Online (Sandbox Code Playgroud)
对于Maven 2.1,您可以通过在Maven设置中添加服务器上的配置来设置超时(~/.m2/settings.xml默认情况下),例如:
<server>
<id>myrepo</id>
<configuration>
<timeout>5000</timeout> <!-- 5 seconds -->
</configuration>
</server>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22476 次 |
| 最近记录: |