我正在尝试在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'points在没有当地的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>
按Alt + F5并从列表中选择您的项目,然后选中“强制更新快照/发布”复选框,然后单击确定。
现在右键单击项目并选择run - > maven build。
第一步:右键单击项目文件夹> Maven>更新项目>确定
然后:右键单击项目文件夹> Run As> Maven build ...
这是您的互联网连接的问题。检查,是否可以使用浏览器访问http://repo.spring.io。如果是,请检查是否需要配置代理服务器。在大多数情况下,我们需要配置代理服务器。
我将帮助您完成在STS或eclipse中设置代理的步骤:
./Apache-maven-3.3.9/conf
。现在在conf
文件夹里面用任何文本编辑器打开setting.xml
。settings.xml
文件中,查找代理标记并将其替换为此。 <proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
<host>
,<port>
,<username>
和<password>
。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
谢谢Aagam Jain和veben。我尝试了这些步骤并没有奏效。原因是缺少代理服务器设置。
将代理设置添加到XML后,应用程序就构建并成功运行。它是在您的步骤和代理服务器设置的组合下运行的。
感谢帮助..