配置Maven以在无法访问Nexus时使用中央存储库
我遇到了这样一种情况:将Nexus配置为所有东西的镜像并不完全适合我的需要。我的Nexus存储库位于VPN后面。如果无法访问Nexus存储库,则无法构建任何内容,因为它已配置为镜像。如果我想构建一个对Nexus存储库没有依赖关系但无法访问的项目,该怎么办?只需使用中央存储库就可以很好地构建,但由于镜像的原因,它不会显示在那里配置Maven以在无法访问Nexus时使用中央存储库,maven,repository,nexus,Maven,Repository,Nexus,我遇到了这样一种情况:将Nexus配置为所有东西的镜像并不完全适合我的需要。我的Nexus存储库位于VPN后面。如果无法访问Nexus存储库,则无法构建任何内容,因为它已配置为镜像。如果我想构建一个对Nexus存储库没有依赖关系但无法访问的项目,该怎么办?只需使用中央存储库就可以很好地构建,但由于镜像的原因,它不会显示在那里 有没有人对如何避开这个问题有什么想法?我认为理想情况下,我想先看看Nexus,但如果它不可访问,我想看看中央存储库。我也愿意接受任何其他建议,以实现任何人都可能拥有的相同目
有没有人对如何避开这个问题有什么想法?我认为理想情况下,我想先看看Nexus,但如果它不可访问,我想看看中央存储库。我也愿意接受任何其他建议,以实现任何人都可能拥有的相同目标。您需要配置多个存储库 maven-3.0.4\conf\settings.xml文件可以这样配置:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups />
<proxies />
<servers>
<server>
<!-- local repository have restricted access -->
<id>central</id>
<username>myusername</username>
<password>mypassword</password>
</server>
<server>
<id>LocalRepository</id>
<username>myusername</username>
<password>mypassword</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>external:*</mirrorOf>
<name>Central</name>
<url>url to repository</url>
</mirror>
<mirror>
<id>LocalRepository</id>
<mirrorOf>LocalRepository</mirrorOf>
<name>repository</name>
<url>url to repository</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>central</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://central/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>LocalRepository</id>
<name>specific repository</name>
<url>repository URL</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>central</activeProfile>
</activeProfiles>
</settings>
中心的
我的用户名
我的密码
本地存储库
我的用户名
我的密码
中心的
外部:*
中心的
指向存储库的url
本地存储库
本地存储库
存储库
指向存储库的url
中心的
中心的
中心的
http://central/
真的
本地存储库
特定存储库
存储库URL
中心的
您需要配置多个存储库
maven-3.0.4\conf\settings.xml文件可以这样配置:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups />
<proxies />
<servers>
<server>
<!-- local repository have restricted access -->
<id>central</id>
<username>myusername</username>
<password>mypassword</password>
</server>
<server>
<id>LocalRepository</id>
<username>myusername</username>
<password>mypassword</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>external:*</mirrorOf>
<name>Central</name>
<url>url to repository</url>
</mirror>
<mirror>
<id>LocalRepository</id>
<mirrorOf>LocalRepository</mirrorOf>
<name>repository</name>
<url>url to repository</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>central</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://central/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>LocalRepository</id>
<name>specific repository</name>
<url>repository URL</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>central</activeProfile>
</activeProfiles>
</settings>
中心的
我的用户名
我的密码
本地存储库
我的用户名
我的密码
中心的
外部:*
中心的
指向存储库的url
本地存储库
本地存储库
存储库
指向存储库的url
中心的
中心的
中心的
http://central/
真的
本地存储库
特定存储库
存储库URL
中心的
满足此类需求的最佳方法是在开发机器上本地运行Nexus
它易于安装和运行,您可以随时指向它
将其配置为代理您的公司Nexus和Central
然后,当您关闭VPN时。。公司代理回购协议将是遥不可及的,但你仍然可以得到其他任何东西。Nexus为您管理一切
我这么做已经很多年了,它让我可以很容易地切换到不同的环境。事实上,对于许多Maven用户来说,这是一种标准做法,对于使用远程存储库(如Gradle或SBT)的其他工具也应该如此。使事情变得更简单。满足此类需求的最佳方法是在您的开发机器上本地运行Nexus 它易于安装和运行,您可以随时指向它 将其配置为代理您的公司Nexus和Central 然后,当您关闭VPN时。。公司代理回购协议将是遥不可及的,但你仍然可以得到其他任何东西。Nexus为您管理一切
我这么做已经很多年了,它让我可以很容易地切换到不同的环境。事实上,对于许多Maven用户来说,这是一种标准做法,对于使用远程存储库(如Gradle或SBT)的其他工具也应该如此。让事情变得简单。这对我来说很好,但作为更大团队的一员,我不想这样做。您实际上是在本地计算机上复制公司存储库,这似乎是重复工作。您可以轻松配置Nexus,定期清理不需要的组件。它将只下载您的构建请求。它基本上类似于使用本地Maven存储库的更强大的扩展。所以你没有复制整个公司回购协议。这对我来说很好,但作为一个更大团队的一部分,我不认为我会这么做。您实际上是在本地计算机上复制公司存储库,这似乎是重复工作。您可以轻松配置Nexus,定期清理不需要的组件。它将只下载您的构建请求。它基本上类似于使用本地Maven存储库的更强大的扩展。所以你不是在复制整个公司回购协议。