Gradletest:测试:无法解析org.junit和任何依赖性

发布于 2025-01-26 06:58:09 字数 901 浏览 4 评论 0原文

我在Intellij中创建了一个gradle项目,每次我构建时,我都会遇到依赖项的错误,它总是像我添加的每个依赖关系一样

GradleTest:test: Could not resolve org.junit

Gradle Daemon started in 2 s 100 ms
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
Could not resolve: org.junit.jupiter:junit-jupiter-api:5.8.1
Could not resolve: org.junit.jupiter:junit-jupiter-engine:5.8.1
Could not resolve: org.junit.jupiter:junit-jupiter-api:5.8.1
Could not resolve: org.junit.jupiter:junit-jupiter-engine:5.8.1

BUILD SUCCESSFUL in 10s

都会遇到相同的错误,我不在离线模式下,我的JDK还

可以.gradle

plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
    useJUnitPlatform()
}

I created an Gradle project in IntelliJ, and everytime I build I run into errors with the dependencies, its always something like

GradleTest:test: Could not resolve org.junit

and

Gradle Daemon started in 2 s 100 ms
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
Could not resolve: org.junit.jupiter:junit-jupiter-api:5.8.1
Could not resolve: org.junit.jupiter:junit-jupiter-engine:5.8.1
Could not resolve: org.junit.jupiter:junit-jupiter-api:5.8.1
Could not resolve: org.junit.jupiter:junit-jupiter-engine:5.8.1

BUILD SUCCESSFUL in 10s

Every dependency that I add will run into the same error, I am not in offline mode and my jdk is ok

my build.gradle

plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
    useJUnitPlatform()
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨敛清荷 2025-02-02 06:58:09

也许为此迟到了,但是(出于某些未知原因),就我而言,5.8.1版本无法从Intellij到达,当我切换到5.8.2时,它可以使用。

Maybe a little late for this but (for some unknown reason), in my case 5.8.1 version was not reachable from IntelliJ, when I switched to 5.8.2 it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文