解决:IDEA创建SpringBoot项目时无法导入依赖问题

本文介绍了在IntelliJ IDEA中创建SpringBoot项目时遇到无法导入依赖问题的解决过程,包括尝试降低SpringBoot版本、修改maven设置文件添加镜像等方法,最终通过使用阿里云的maven镜像成功解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决:IDEA创建SpringBoot项目时无法导入依赖问题

1、问题

在创建SringBoot项目时候,无法正常导入依赖的jar包,错误显示如下:
“Project ‘org.springframework.boot:spring-boot-starter-parent:2.0.0.RELEASE’ not fond more…”
在这里插入图片描述

 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath/>
    </parent>
    
    <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

2、 摸索思考

记得之前上课的时候用Eclipse 也有类似的问题 解决办法就是将版本降级,只有降级了,才能兼容当前使用工具或者JDK版本的一个环境, 但是尝试修改过后并没有什么卵用
查找网上类似文章解决办法说要添加maven的镜像,打开maven的setting.xml修改过后如下:

<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
    
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
     <mirror>
     <id>mirrorId</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://central.maven.org/maven2/</url>
       </mirror>
  </mirrors>

修改过后
依旧没有解决。

3、问题解决

多番摸索,尝试过后,无果,决定重置整个setting文件,把添加的镜像改成阿里的,成功,正确代码如下:

...
  <profile>
        <id>jdk-1.8</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.8</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
        </properties>
    </profile>
 <mirrors>
      <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
  </mirrors>
  ...

成功自动导入jar包!是开心的哈哈哈
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值