Gradletest:测试:无法解析org.junit和任何依赖性
我在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许为此迟到了,但是(出于某些未知原因),就我而言,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.