简体   繁体   中英

Maven unable to resolve dependencies for Spring Boot and JUnit

I'm trying to learn Spring Boot hands-on and importing the boilerplate for basic spring boot application through Spring Starter using my IntelliJ IDE, but Maven is unable to resolve all dependencies and my project is missing out on important dependencies. I can't figure out the reason for this.

First I thought the problem was using JDK8 for newer versions of the SpringFramework, then I installed JDK11 but the same problem persists and as far as I can understand POM.xml has all the dependencies listed in it.

Screenshot of IDE to get an idea

    <?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.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.selfspring</groupId>
    <artifactId>conference-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>conference-demo</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-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

    </project>```

here is all the dependencies it is unable to resolve:

Cannot resolve org.hibernate.validator:hibernate-validator:6.0.18.Final
Cannot resolve org.hamcrest:hamcrest:2.1
Cannot resolve org.ow2.asm:asm:5.0.4
Cannot resolve org.springframework:spring-expression:5.2.5.RELEASE
Cannot resolve org.junit.platform:junit-platform-engine:1.5.2
Cannot resolve net.minidev:accessors-smart:1.2
Cannot resolve net.bytebuddy:byte-buddy:1.10.8
Cannot resolve jakarta.xml.bind:jakarta.xml.bind-api:2.3.3
Cannot resolve org.springframework:spring-aop:5.2.5.RELEASE
Cannot resolve com.fasterxml:classmate:1.5.1
Cannot resolve org.junit.jupiter:junit-jupiter-api:5.5.2
Cannot resolve org.mockito:mockito-junit-jupiter:3.1.0
Cannot resolve org.opentest4j:opentest4j:1.2.0
Cannot resolve org.objenesis:objenesis:2.6
Cannot resolve org.springframework:spring-webmvc:5.2.5.RELEASE
Cannot resolve org.springframework.boot:spring-boot-test-autoconfigure:2.2.6.RELEASE
Cannot resolve net.bytebuddy:byte-buddy-agent:1.10.8
Cannot resolve org.junit.jupiter:junit-jupiter:5.5.2
Cannot resolve org.springframework.boot:spring-boot-test:2.2.6.RELEASE
Cannot resolve jakarta.validation:jakarta.validation-api:2.0.2
Cannot resolve org.jboss.logging:jboss-logging:3.4.1.Final
Cannot resolve net.minidev:json-smart:2.3
Cannot resolve org.springframework:spring-test:5.2.5.RELEASE
Cannot resolve org.assertj:assertj-core:3.13.2
Cannot resolve jakarta.activation:jakarta.activation-api:1.2.2
Cannot resolve org.skyscreamer:jsonassert:1.5.0
Cannot resolve org.springframework.boot:spring-boot-starter-test:2.2.6.RELEASE
Cannot resolve org.mockito:mockito-core:3.1.0
Cannot resolve com.vaadin.external.google:android-json:0.0.20131108.vaadin1
Cannot resolve com.jayway.jsonpath:json-path:2.4.0
Cannot resolve org.junit.jupiter:junit-jupiter-params:5.5.2
Cannot resolve org.xmlunit:xmlunit-core:2.6.4
Cannot resolve org.springframework:spring-jcl:5.2.5.RELEASE
Cannot resolve org.apiguardian:apiguardian-api:1.1.0
Cannot resolve org.springframework:spring-beans:5.2.5.RELEASE
Cannot resolve org.junit.jupiter:junit-jupiter-engine:5.5.2
Cannot resolve org.junit.platform:junit-platform-commons:1.5.2

Try nuking your.m2 folder, and then pull dependencies again. I usually do it like this: delete everything from.m/repo, I go to intellij and add space in pom.xml and delete it so it offers me to pull changes that were made in pom.xml

EDIT: If that does not help, you can always run

mvn clean - clear dependencies so you get something like a clean slate

mvn install - initiates the pulling of dependencies again

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