简体   繁体   中英

Dependency 'org.springframework.boot:spring-boot-starter-validation:2.5.1' not found

How can I solve the issue of "Dependency 'org.springframework.boot:spring-boot-starter-validation:2.5.1' not found" ?

My pom.xml file loks like this:

<?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.5.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>JavaDeveloperTask</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</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>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
            </plugin>
        </plugins>
    </build>

</project>

I have added

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

But it still gives me the error. What could be th cause of this?

Works for me. Central repo have this dependency: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-validation/2.5.1/

So i don't see why it should not work. Maybe there was some kind of network issue.

Try to remove it from local maven repo and download again. You can find maven repo in your user home dir .m2 , delete .m2/repository/org/springframework/boot/spring-boot-starter-validation/2.5.1 folder

You should try to close the project and re-open it, the dependency will get downloaded by itself.

Worked in my case.

@ekm0d. I had the same problem using the Intellij IDEA . Here what I did and worked for me after inserting this on pom.xml :

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
</dependency>
  1. Right-click on the project file.
  2. Click on Maven
  3. Click on Reload Project
  4. Wait the poem.xml archive reload

I hope it works for you too :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM