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

重装Ubuntu 17.10后Maven无法下载Spring依赖求助

Troubleshooting Maven Dependency Download Issues on Ubuntu 17.10

Hey there, let's figure out why Maven's failing to grab Spring dependencies after your Ubuntu 17.10 reinstall—especially since Gradle works perfectly, so this is almost certainly a Maven-specific configuration hiccup. Here are the steps I'd recommend working through:

1. Check Your Maven settings.xml Configuration

Maven relies heavily on this file for repository and proxy settings, and it's easy to lose custom configs after a system reinstall.

  • The file lives either at ~/.m2/settings.xml (user-specific) or <maven-install-dir>/conf/settings.xml (global). If it doesn't exist, create the user-specific one.
  • Make sure you have valid repository mirrors set up—many default Maven mirrors can be slow or unreachable. Try adding a reliable domestic mirror like this:
    <settings>
      <mirrors>
        <mirror>
          <id>aliyun-public</id>
          <mirrorOf>central</mirrorOf>
          <url>https://maven.aliyun.com/repository/public</url>
        </mirror>
        <mirror>
          <id>aliyun-spring</id>
          <mirrorOf>spring-milestones,spring-snapshots</mirrorOf>
          <url>https://maven.aliyun.com/repository/spring</url>
        </mirror>
      </mirrors>
    </settings>
    

2. Verify Maven Version Compatibility

Ubuntu 17.10's default Maven package might be outdated, which can cause compatibility issues with newer Spring Boot versions.

  • Run mvn -v to check your current version. If it's older than 3.6.x, consider upgrading:
    • You can download the latest stable version from the official Maven site, extract it, and add its bin directory to your PATH.
    • Alternatively, use a version manager like SDKMAN to install and manage Maven versions cleanly.

3. Check for Proxy Conflicts

Gradle often auto-detects system proxy settings, but Maven needs explicit configuration if you're behind a proxy.

  • If you use a proxy, add these settings to your settings.xml:
    <settings>
      <proxies>
        <proxy>
          <id>work-proxy</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>your-proxy-host</host>
          <port>your-proxy-port</port>
          <!-- Add username/password if required -->
          <!-- <username>proxy-user</username> -->
          <!-- <password>proxy-pass</password> -->
          <nonProxyHosts>localhost|127.0.0.1|*.your-local-domain.com</nonProxyHosts>
        </proxy>
      </proxies>
    </settings>
    
  • If you don't use a proxy, make sure there are no leftover proxy entries in settings.xml that could block connections.

4. Clear Maven Local Repository Cache

Corrupted cache files in your local repository can prevent successful dependency downloads.

  • Run this command to wipe the cache:
    rm -rf ~/.m2/repository
    
  • Then re-run mvn clean install—Maven will re-download all dependencies from scratch.

5. Validate Your Project's pom.xml

Double-check that your Spring Boot project's POM has the correct parent dependency and repository settings:

  • Ensure the Spring Boot parent is properly defined:
    <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.7.14</version> <!-- Use a version compatible with your project -->
      <relativePath/>
    </parent>
    
  • Make sure there are no typos in dependency group IDs, artifact IDs, or version numbers.

If none of these steps fix the issue, run mvn clean install -X to enable debug logging. This will show detailed information about where the download is failing, which will help pinpoint the exact problem.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 03:49:12