您的位置:首页 > 编程语言 > Java开发

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

2020-04-20 12:53 3515 查看

解决: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包!是开心的哈哈哈

  • 点赞
  • 收藏
  • 分享
  • 文章举报
Axin@xin 发布了2 篇原创文章 · 获赞 0 · 访问量 813 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐