You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maven与Nexus Repository集成配置问题求助

Troubleshooting Maven Still Using Central Repo Instead of Nexus

Hey there, let's work through why your Maven build is still pulling from the central repository instead of your Nexus maven_ub repo. Here are step-by-step checks and fixes to resolve this:

1. Verify Which settings.xml Maven is Actually Using

Maven prioritizes the user-specific settings file over the global one in most cases. The user settings are located at C:\Users\<YourUsername>\.m2\settings.xml, while you modified the global one at C:\Program Files\apache-maven-3.3.9\conf\settings.xml.

  • Run this command to see the effective settings Maven is applying:
    mvn help:effective-settings
    
  • Look for the <mirrors> section in the output. If your Nexus mirror isn't listed, Maven is loading a different settings.xml. You can either:
    • Update the user-specific settings.xml with your mirror configuration, or
    • Force Maven to use your modified global settings by running builds with:
      mvn clean install -s "C:\Program Files\apache-maven-3.3.9\conf\settings.xml"
      

2. Confirm Your Nexus Repository Configuration

Your maven_ub repo needs to be set up correctly to proxy the central repository:

  • Log into your Nexus admin panel and check if maven_ub is a Proxy Repository (not a Hosted repository). Hosted repos only store local artifacts and won't pull from central.
  • Ensure the proxy repository is configured to point to Maven Central (default URL: https://repo.maven.apache.org/maven2/) and that the repository status shows as Online.
  • Test if you can access the repo directly via browser: http://1.2.3.4:8081/repository/maven_ub/ — you should see the repository's directory structure.

3. Adjust the mirrorOf Scope

Your current <mirrorOf>central</mirrorOf> only mirrors the official central repo. If your project uses other repositories (like Spring's repo, for example), Maven will bypass your Nexus mirror to pull from those.

  • To mirror all repositories (a common setup for internal Nexus usage), change the value to:
    <mirrorOf>*</mirrorOf>
    
    Note: If you have local or specialized repos that shouldn't be mirrored, you can exclude them with syntax like <mirrorOf>*,!local-repo</mirrorOf>.

4. Clear Maven Local Repository Cache

Maven might be using cached dependencies from your local repo instead of fetching from Nexus.

  • Delete the relevant dependency folders in C:\Users\<YourUsername>\.m2\repository, or
  • Run your build with the -U flag to force dependency updates:
    mvn clean install -U
    

5. Check for Repository Configurations in Your Project's pom.xml

If your project's pom.xml includes explicit <repositories> or <pluginRepositories> sections, these can override the mirror settings in settings.xml.

  • Open your project's pom.xml and look for these sections. If they exist, either:
    • Remove them to rely on your Nexus mirror, or
    • Ensure your mirrorOf configuration covers these repos (using <mirrorOf>*</mirrorOf> as mentioned earlier).

内容的提问来源于stack exchange,提问作者Shalika

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:39:21