创建springboot项目时,pom.xml中parent报错

下载Maven

进入maven官网 http://maven.apache.org/download.cgi.
找到并点击apache-maven-3.6.2-bin.zipi.下载压缩包

配置Maven环境变量

具体见 https://jingyan.baidu.com/article/ce09321ba734f02bff858fcf.html.

使用settings

打开eclipse
window->preference->在搜索框中搜索user settings
引入settings文件如果服务器是用的代理服务器需要在settings中的proxy里设置一下<proxy

创建springboot项目时,pom.xml中parent报错

手动创建项目

进入spring官网
https://start.spring.io/.

pom.xml中parent标红报错

Project build error: Non-resolvable parent POM for com.example:demo-1:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:1.5.4.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.4.RELEASE from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: nodename nor servname provided, or not known and ‘parent.relativePath’ points at no local POM作者

很有可能是在使用maven时使用的不是自己字啊环境变量中配置的maven
解决办法
eclipse中 window ->preferences
创建springboot项目时,pom.xml中parent报错
点击Add,把在环境变量中配置的maven文件添加进去,并勾选上,点击Apply,Apply and Close

  • 进入cmd命令行
  • 进入项目根目录
  • mvn clean 等待将原先的maven库全部删除
  • mvn packeage 重新创建maven
  • 完成后在eclipse右击项目,点击refresh等待更新项目后会出现jar包