[英]spring boot pom.xml Failure to transfer
我剛剛創建了一個新的 spring boot projet,我在 pom.xml 中有一個問題,我不知道如何解決它,請幫忙,謝謝大家。
父標簽中的 pom.xml 中的錯誤是:
項目構建錯誤:com.example:ProjetTest:0.0.1-SNAPSHOT 的不可解析父 POM:無法從https:/傳輸 org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE /repo.maven.apache.org/maven2已緩存在本地存儲庫中,在central 的更新間隔已過或強制更新之前不會重新嘗試解析。 原始錯誤:無法傳輸工件 org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE from/to central ( https://repo.maven.apache.org/maven2 ):連接被拒絕: 連接和 'parent.relativePath' 指向沒有本地 POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>Ticketing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Ticketing</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.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-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
嘗試的事情
<project>
標簽,如下所示:-
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Other stuff of the pom.xml here -->
</project>
<relativePath/>
並且父項將如下所示:-
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- use your specific version here -->
<version>2.0.0.RELEASE</version>
</parent>
如果仍然沒有解決,那么它可能是各種各樣的事情,例如:-
M2_FOLDER_LOCATION\\.m2\\repository\\org\\springframework\\boot\\spring-boot-parent
然后重新導入項目。我面臨同樣的問題。 我按照以下步驟操作:
現在應該可以正常工作了。
relativePath
需要一個路徑,如下所示:
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
您可能需要做的就是刪除<relativePath/>
並使您的父級看起來像這樣:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
我在家里練習,所以沒有代理與一個 ISP,這導致了一個問題,但之前在任何項目中都沒有,僅供練習。 因此刪除了 .m2 文件夾中的 setting.xml(在 Windows 操作系統中)。 pom.xml 中的父錯誤消失了
就我而言,這是一個互聯網代理問題。
這也可能是 Internet 代理的問題。 檢查您的 Internet 代理設置。 不知何故,由於代理,MAVEN 無法下載依賴項。
如果您使用代理,請按照以下鏈接中提到的步驟https://maven.apache.org/guides/mini/guide-proxies.html
我使用了以下配置來使其工作。
<settings>
<proxies>
<proxy>
<id>proxy</id>
<active>true</active>
<protocol>http</protocol>
<!--
<username>....</username>
<password>....</password>
-->
<host>proxy.abcd.com</host>
<port>1234</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
</settings>
我也面臨着與作者相同的問題,我使用代理並且我有一個存儲來保存所有 maven 依賴項,因此在 maven 配置中,我將 maven 設置為從我制作的存儲中下載。 但我仍然面臨這個問題。 大家有什么解決辦法嗎?
我使用 vscode 並且我已經安裝了 Java 插件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.