我正在尝试在STS中创建一个默认的spring boot应用程序 . 它在STS文件中创建了一个“spring starter project” - > . 项目创建后未进行任何更改 . 错误立即显示在POM文件中......
它失败并出现以下错误 . 一切都是默认的,解决这个问题需要什么?
项目构建错误:com.example的不可解析的父POM:hello-boot:0.0.1-SNAPSHOT:无法从https://repo.maven.apache.org/maven2转移org.springframework.boot:spring-boot-starter-parent:pom:2.0.5.RELEASE缓存在本地存储库中,在中心的更新间隔过去或强制更新之前,不会重新尝试解析 . 原始错误:无法传输工件org.springframework.boot:spring-boot-starter-parent:pom:2.0.5.RELEASE from / to central(https://repo.maven.apache.org/maven2):repo.maven.apache.org和'parent.relativePath'指向无本地POM
pom文件如下:http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0
<groupId>com.example</groupId>
<artifactId>first-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>first-boot</name>
<description>Hello Spring Boot in STS</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
4 回答
First :右键单击项目文件夹> Maven>更新项目>确定
Then :右键单击项目文件夹> Run As> Maven build ...
检查"Update Snapshots"
将"clean install"添加到"Goals"字段
点击"Run"
谢谢Aagam Jain和veben . 我尝试了这些步骤并没有奏效 . 原因是缺少代理服务器设置 .
将代理设置添加到XML后,应用程序就构建并成功运行 . 它是在您的步骤和代理服务器设置的组合下运行的 .
感谢帮助..
这是您的互联网连接的问题 . 如果您可以使用浏览器访问http://repo.spring.io,请检查 . 如果是,请检查是否需要配置代理服务器 . 在大多数情况下,我们需要配置代理服务器 .
我将帮助您完成在STS或eclipse中设置代理的步骤:
从here下载Apache Maven 3.5.4工具 .
假设您下载了zip文件,现在将其解压缩 .
解压后,在里面导航:
./Apache-maven-3.3.9/conf
. 现在在conf
文件夹里面用任何文本编辑器打开setting.xml
.现在在
settings.xml
文件中,查找代理标记并将其替换为此标记 .请使用您的代理设置更改
<host>
,<port>
,<username>
和<password>
.现在打开Eclipse . 转到
Window
- >Preference
- >maven
- >User Settings
. 现在在user settings
输入框中输入settings.xml文件的路径,然后单击Apply
然后单击Ok
.[screenshot for reference]
.force update of snapshot/release
并单击ok
.以下是为Maven配置代理服务器的文档:https://maven.apache.org/guides/mini/guide-proxies.html
按Alt F5并从列表中选择您的项目,然后选中“强制更新快照/发布”复选框,然后单击确定 .
现在右键单击项目并选择run - > maven build .