天天看點

SpringBoot pom.xml unknown error

參考:https://blog.csdn.net/yaowanliang/article/details/83185808

SpringBoot pom.xml unknown error

pom檔案報Unknown error

pom.xml内容:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.9.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>

	<properties>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>
           

把maven項目重新clean,install後有接着提示下面的警告

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:demo:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencyManagement.dependencies.dependency.exclusions.exclusion.artifactId' for org.quartz-scheduler:quartz:jar with value '*' does not match a valid id pattern. @ org.springframework.boot:spring-boot-dependencies:2.1.9.RELEASE, D:\repos\org\springframework\boot\spring-boot-dependencies\2.1.9.RELEASE\spring-boot-dependencies-2.1.9.RELEASE.pom, line 2615, column 25
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
           

網上提供的解決辦法:

1. 降低spring-boot-starter-parent的版本,把2.1.9降低為2.1.1

2. 項目右鍵 - Maven - Update Project - 選中Force Update of Snapshots/Releases 進行強制更新

根據網上解決辦法我也進行多次嘗試,終于找到解決方法,方法如下:

1. 降低spring-boot-starter-parent的版本,把2.1.9降低為2.1.4

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.1.4.RELEASE</version>
	<relativePath/> <!-- lookup parent from repository -->
</parent>
           

2. 删除本地maven庫repos裡面org.springframework.boot對應的檔案夾boot

SpringBoot pom.xml unknown error

3. 把maven項目重新clean,install (這個時候就可以看到項目對應的pom.xml不會報錯)

4. 項目右鍵 - Maven - Update Project