[英]In the spring tool suite, we added maven dependencies using pom.xml, but the shape is different as shown in the picture, why is that?
[英]Spring Tool Suite Maven project error in pom.xml at xsi:schemaLocation
我剛開始我的第一個 maven 項目,但在 pom.xml 文件的第一行 xsi:schemaLocation 部分出錯。
我的 pom.xml 是
<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.demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Demo Course API</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
</plugin>
</plugins>
</build>
</project>
錯誤描述的前幾行是
Failure to transfer com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0 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 com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0 from/to central (https://repo.maven.apache.org/maven2): The operation was
cancelled. org.eclipse.aether.transfer.
我剛剛從 spring 入門指南中復制了它,但仍然出現錯誤。不知道該怎么辦。 我的 mvn -v 是 3.5.2
M2E版本與maven-jar-plugin 3.1.2版本不兼容。
在 M2E 或 maven-jar-plugins 的開發團隊解決問題之前,您必須在 pom.xml 文件中添加以下行才能解決此問題:
</project>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
嘗試在 pom.xml 中包含此依賴項並檢查:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.0.pr2</version>
</dependency>
分析錯誤描述對解決上述問題有很大幫助。 錯誤計數為 53。
首先,如@Duho 所述,添加 jackson 依賴項有助於減少一些錯誤,現在錯誤計數減少到 35。然后錯誤出現在 hibernate 驗證器依賴項中,我通過添加 hibernate 驗證器依賴項來解決此問題。 可以通過右鍵單擊項目-->Maven-->Add Dependency 來添加依賴項。
然后我發現maven從中央存儲庫下載了一些不完整的文件到本地存儲庫,下載不完整。 因此,我從 Users/'myName'/.m2/repository 文件夾中刪除了所有帶有“.lastUpdated”擴展名的文件。
然后通過右鍵單擊更新項目--> Maven--> 更新項目幫助解決所有錯誤。
它對我有用..希望這對有同樣問題的人有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.