如果公司maven存储库处于脱机状态或关闭状态,如何使用internet进行maven构建?
我在POM中定义了一个公司存储库:如果公司maven存储库处于脱机状态或关闭状态,如何使用internet进行maven构建?,maven,repository,pom.xml,offline,artifactory,Maven,Repository,Pom.xml,Offline,Artifactory,我在POM中定义了一个公司存储库: <distributionManagement> <repository> <id>central</id> <name>libs-release-local</name> <url>http://bi-pub.wgresorts.com:8081/artifactory/libs-release-local</ur
<distributionManagement>
<repository>
<id>central</id>
<name>libs-release-local</name>
<url>http://bi-pub.wgresorts.com:8081/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>libs-snapshot-local</name>
<url>http://bi-pub.wgresorts.com:8081/artifactory/libs-snapshot-local</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
中心的
libs本地发布
http://bi-pub.wgresorts.com:8081/artifactory/libs-本地发布
快照
本地快照库
http://bi-pub.wgresorts.com:8081/artifactory/libs-快照本地
假的
但他们不断地拔掉、移动或重新启动那个盒子,所以有时候它不可用。有没有办法告诉我的maven poms“尝试使用公司存储库,但如果它停止使用,请使用internet?”我尝试在分发管理部分之外指定存储库和插件存储库,但没有用
有谁可以给我指点一下吗
在settings.xml中,我定义了镜像和本地存储库:
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>repo</name>
<url>http://bi-pub.wgresorts.com:8081/artifactory/repo</url>
<id>repo</id>
</mirror>
</mirrors>
<localRepository>C:\apache-maven-3.1.1\.m2\repository</localRepository>
*
回购
http://bi-pub.wgresorts.com:8081/artifactory/repo
回购
C:\apache-maven-3.1.1\.m2\存储库
我不想根据IT部门的突发奇想不断地更改settings.xml,我可以设置它以便它尝试使用吗?如果公司的设置失败,它会转到internet吗
编辑
如果您使用了id central,您必须首先创建一个带有central的pom,该pom指向internet上的真实pom,然后才能修复此问题。它也可以指向您的公司存储库,但具有不同的ID。如果您的公司存储库关闭,它将转到internet
我认为您可能还必须从settings.xml中删除mirror部分。不管是好是坏,二进制存储库是生产流程中的一个关键部分。 你不会问“如果我的网站关闭,我有什么选择”,是吗?你只要保持你的网站。同样的情况,您的IT部门应该意识到这一点
您可以在DR模式(主动/被动)甚至HA模式(主动/主动)下运行Artifactory。您的存储库拥有全天候运行的所有方法,因此您确实不需要这些解决方法。首先,您的settings.xml文件不正确
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
关系
*
http://localhost:8081/nexus/content/groups/public
关系
中心的
http://central
真的
真的
中心的
http://central
真的
真的
除此之外,setting.xml
中的定义用于阅读,而pom.xml
distributionManagement
中的定义用于编写,这意味着部署工件或站点
因此,在这两种情况下,您都需要像JBaruch所提到的那样启动存储库并工作。如果您的IT部门无法处理此类案例(基本IT运营),我几乎不会考虑这一点
您公司的每个构建都取决于存储库管理器的可用性,无论是下载工件还是部署构建结果,以及管道的后续步骤。但即使nexus/artifactory关闭,我也应该能够进行构建。我理解部署被破坏,但肯定有一种方法不必完全依赖于一台服务器的启动。我将删除uniqueVersion。你为什么说这是错的?我有4个存储库,2个用于发布,2个用于快照,分别用于插件和其他工件。这是默认配置,我没有修改它。如果你已经构建了项目状态,一旦你可以通过mvn--offline
离线,那么你就不需要联系你的neuxs/artifactory。但是如果它发生在你可以进行mvn--offline之前,你如何恢复呢?遗憾的是,你高估了我们的能力/服务器可靠性(必须共享硬件):我只能向您指出我以前给您的答案。在不知道的情况下通过Internet返回存储库是一个非常糟糕的主意。我不确定问题出在哪里?只需从设置中删除配置文件。我最终删除并重新创建了存储库和我的maven设置文件,因为元数据似乎已损坏。如果您在公司服务器关闭之前不脱机,则似乎很难从该状态恢复。这似乎是一个常见问题。我想知道,鉴于所有人的看法,为什么该问题没有投票。可能是重复的