使用Nexus代理仓库执行Maven打包报错,咨询优先排查方向
Based on your error message and configuration details, here are the first critical things you should check to resolve this issue:
Verify Maven repository version permissions in
settings.xml
Your currentsettings.xmlonly defines repository IDs and URLs, but doesn’t specify which repositories handle release vs snapshot versions. Maven defaults to allowing both unless configured otherwise. Add the<releases>and<snapshots>blocks to enforce correct behavior:<repository> <id>aliyun_release</id> <url>http://192.168.xxx.xxx:8081/repository/aliyun_release/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>aliyun_snapshot</id> <url>http://192.168.xxx.xxx:8081/repository/aliyun_snapshot/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository>This tells Maven to use
aliyun_releaseexclusively for release artifacts andaliyun_snapshotfor snapshots, aligning with your Nexus proxy setup.Check Nexus proxy repository version policies
Log into your Nexus 3.19.1 instance and verify each proxy’s configuration:- Navigate to Repository > Repositories
- For
aliyun_release, confirm its Version policy is set to Release - For
aliyun_snapshot, confirm its Version policy is set to Snapshot
While the error points to Maven targeting the wrong repository, ensuring Nexus has the correct policy prevents future mismatches.
Look for unintended Maven mirror configurations
Check if yoursettings.xmlincludes a<mirrors>section that redirects all requests toaliyun_release. A mirror with<mirrorOf>*</mirrorOf>would force snapshot dependencies to be fetched from the release proxy, triggering the 400 error. Adjust mirrors to exclude snapshot repositories, or create separate mirrors for release and snapshot traffic.Confirm Nexus proxy remote URLs are mapped correctly
Ensurealiyun_releaseproxies the originalrdc-releasesURL (https://repo.rdc.aliyun.com/repository/36007-release-InunWS/), andaliyun_snapshotproxiesrdc-snapshots(https://repo.rdc.aliyun.com/repository/36007-snapshot-JRXl8h/). Swapped URLs would cause the release proxy to fetch from a remote snapshot repo (or vice versa), conflicting with Nexus’s version policy.Check project pom.xml for conflicting repository settings
Some projects define repositories directly inpom.xml. If yourriskcontrol-servicepom only referencesaliyun_release, Maven won’t know to look for snapshots inaliyun_snapshot. Ensure the pom inherits settings fromsettings.xmlor explicitly includes both repositories with proper release/snapshot enablement.
内容的提问来源于stack exchange,提问作者shike

