Импорт org.springframework.boot.test не может быть разрешен - PullRequest
0 голосов
/ 01 октября 2019

В настоящее время я работаю над приложением Spring, использующим SpringBoot. Для управления зависимостями этого проекта я использую Gradle.

Я хотел реализовать некоторые тесты, но у меня появилась такая ошибка: «Не удается разрешить импорт org.springframework.boot.test».

Вот код.

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
class ClassTest {

    @Test
    public void contextLoads() {
    }

}

И содержимое build.gradle

plugins {
    id "com.moowork.gulp" version "1.2.0"rk.node" version "1.2.0"
    id "org.springframework.boot" version "2.1.5.RELEASE"
    id "java"
}
configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

test {
    useJUnitPlatform()
}

dependencies {
    implementation "org.springframework.boot:spring-boot-starter-web"
    developmentOnly "org.springframework.boot:spring-boot-devtools"
    testImplementation "org.springframework.boot:spring-boot-starter-test"


    implementation "org.springframework.boot:spring-boot-starter-thymeleaf"
    implementation "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect"

    testCompile "org.junit.jupiter:junit-jupiter:5.4.2"

    annotationProcessor "org.projectlombok:lombok"
    implementation "org.projectlombok:lombok"

    implementation "org.apache.commons:commons-csv:1.1"

    implementation "org.apache.commons:commons-math3:3.0"
}

Упрощенная трассировка стека следующая:

java.lang.Error: Unresolved compilation problems: 
The import org.springframework.boot.test cannot be resolved
The import org.springframework.test cannot be resolved
SpringRunner cannot be resolved to a type
Class<SpringRunner> cannot be resolved to a type
SpringBootTest cannot be resolved to a type

at climenvi.webapp.ClassTest.<init>(ClassTest.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)

Я пробовал некоторые решения, уже найденные для этого, но ничего не устранило проблему. Не могли бы вы мне помочь, пожалуйста ? Спасибо за вашу помощь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...