首页 文章

为什么我在IntelliJ中获得Gradle配置构建错误junit5?

提问于
浏览
1

我使用spring boot初始化程序创建了干净的项目,并且我得到了配置构建错误 . 我收到的消息是: Could not find org.junit:junit-bom:5.4.0-SNAPSHOT. 但是在我的gradle文件中我不知道它错了吗?

buildscript {
    ext {
        springBootVersion = '2.2.0.BUILD-SNAPSHOT'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 11

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


dependencies {
    implementation('org.springframework.boot:spring-boot-starter-security')
    implementation('org.springframework.boot:spring-boot-starter-web')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
    testImplementation('org.springframework.security:spring-security-test')
}

2 回答

  • 0

    你're using a development (snapshot) version of Spring Boot that refers to a development (snapshot) version of JUnit 5, but you have not added JUnit'的快照存储库:https://oss.sonatype.org/content/repositories/snapshots/org/junit/junit-bom/5.4.0-SNAPSHOT/

    repositories {
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
    

    但是你最好使用普遍可用的版本 .

  • 0

    Junit依赖性带有 "spring-boot-starter-test" ,它可能在您的spring版本中不可用 . 尝试更改 spring 版本或使用最新版本,并试一试 .

相关问题