Spring Boot Starter Web Dependency 提供缺少工件的错误 [英] Spring Boot Starter Web Dependency giving error of missing artifacts

查看:72
本文介绍了Spring Boot Starter Web Dependency 提供缺少工件的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我添加 Spring Boot Starter Web 依赖项时,它给出了缺少工件的错误

When I add Spring Boot Starter Web dependency, it gives error of missing artifacts

当我删除 web 依赖项时,项目会运行,但我希望我的项目也有 web 依赖项.

When I remove the web dependency, the project runs, but I want the web dependency as well for my project.

下面是我的 POM.xml 文件

Below is my POM.xml file

<?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>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.4.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.example</groupId>
        <artifactId>firstproject</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>firstproject</name>
        <description>Demo project for Spring Boot</description>

        <properties>
            <java.version>1.8</java.version>
            <maven-jar-plugin.version>3.1.1</maven-jar-plugin.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-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>
        </project>

以下是错误列表:

推荐答案

这种情况发生在我身上几次,当我更改 spring boot 版本时.

It happened with me couple of times, When I changed the spring boot version.

每当您更改 Spring Boot 版本时,所有依赖项都会从 Internet 下载,有时下载的 jar 文件会损坏或不完整,但是由于 jar 仍在您的 .m2 文件夹中,maven 不会更正它.但是您的 mvn 安装失败,因为它无法读取 jar.

Whenever you change the spring boot version all dependency gets downloaded from internet and sometime few jar files download gets corrupted or incomplete , however since jar is still there in your .m2 folder, maven doesn't correct it. However your mvn install fails because it can't read jar.

为了解决这个问题,有两种方法

In order to solve this problem there are two ways

  1. 导航到您的 .m2 文件夹并找到 jars 并将其删除,同时删除 m2e-lastUpdated.properties 文件并运行 mvn clean install

  1. Navigate to your .m2 folder and locate the jars and delete it also delete m2e-lastUpdated.properties file and run mvn clean install

您可以将 M2_HOME 更改为不同的位置并执行 mvn clean install

You can change your M2_HOME to different location and execute mvn clean install

在您当前的情况下,hibernate 验证器 jar 的构建失败,因此删除它并运行 mvn clean install 但您的问题不会结束,您可能会发现另一个已损坏的 jar.

In your current case, build is failing for hibernate validator jar, so delete same and run mvn clean install but your problem will not end , you might find another jar which is corrupted.

对所有罐子重复这个过程

Repeat the process for all jars

祝你好运!

这篇关于Spring Boot Starter Web Dependency 提供缺少工件的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆