Java Maven不使用本地存储库
我的Maven配置有一个小问题。这里的所有其他问题和答案都没有解决我的问题,所以我开始一个新问题 我的问题是,我的Maven没有使用本地存储库。它总是从远程存储库获取工件 下载工件或构建项目时,工件会安装在本地存储库中,因此路径是正确的 问题是:当我构建一个快照项目时,它只安装在本地存储库中(应该是这样的,不要每次都在我的nexus上发布它)。当我在pom.xml中构建另一个项目时,将前一个项目作为依赖项,maven希望从nexus服务器下载它没有找到的工件,而不是从本地存储库获取它 这是我的maven配置:Java Maven不使用本地存储库,java,maven,nexus,Java,Maven,Nexus,我的Maven配置有一个小问题。这里的所有其他问题和答案都没有解决我的问题,所以我开始一个新问题 我的问题是,我的Maven没有使用本地存储库。它总是从远程存储库获取工件 下载工件或构建项目时,工件会安装在本地存储库中,因此路径是正确的 问题是:当我构建一个快照项目时,它只安装在本地存储库中(应该是这样的,不要每次都在我的nexus上发布它)。当我在pom.xml中构建另一个项目时,将前一个项目作为依赖项,maven希望从nexus服务器下载它没有找到的工件,而不是从本地存储库获取它 这是我的m
<?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">
<localRepository>C:\Users\Marc\.m2\repository</localRepository>
<interactiveMode>false</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<pluginGroups>
</pluginGroups>
<servers>
<server>
<id>releases</id>
<username>MY_USERNAME</username>
<password>MY_PASSWORD</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
<server>
<id>snapshots</id>
<username>MY_USERNAME</username>
<password>MY_PASSWORD</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
<server>
<id>nexus</id>
<username>MY_USERNAME</username>
<password>MY_PASSWORD</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
</servers>
<profiles>
<profile>
<id>nexussrv</id>
<repositories>
<repository>
<id>snapshots</id>
<url>http://nexus/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>releases</id>
<url>http://nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>nexus</id>
<url>http://nexus/content/groups/public</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexussrv</activeProfile>
</activeProfiles>
</settings>
C:\Users\Marc\.m2\repository
假的
假的
释放
我的用户名
我的密码
664
775
快照
我的用户名
我的密码
664
775
关系
我的用户名
我的密码
664
775
nexussrv
快照
http://nexus/content/repositories/snapshots
真的
总是
假的
释放
http://nexus/content/repositories/releases
真的
总是
假的
关系
http://nexus/content/groups/public
nexussrv
从nexus下载并将工件(快照和发布)发布到nexus可以使用此配置,但它不使用本地存储库中的工件
谢谢你的帮助 您已配置从快照nexus下载快照(
始终
)。因此,即使您的本地缓存(~/.m2/存储库
)有更新版本的快照,maven也会尝试从配置的服务器下载它(http://nexus/content/repositories/snapshots
)
考虑更改快照条目的updatePolicy。例如,如果您的CI服务器每天(早上)向SNAPSHOT nexus部署快照,请将更新策略更改为
daily
如果您将配置更改为always
,它仍将尝试从nexus下载,因为您必须在pom.xml中禁用nexus配置
请注意,pom.xml
中的
标记将优先于settings.xml
mhh中定义的内容。我将它从always设置为daily,但它仍然尝试从nexus接收它。如前所述,maven然后每天检查nexus一次。这仅在您有一些快照的情况下可用(例如,如果CI服务器部署了快照)。如果nexus上永远不会有shnapshots,那么应该将updatePolicy设置为never。