我使用gradle init创建了一个简单的java应用程序。我正在使用Intellij 2021.2.2。
当我构建这个项目时,我得到了关注。

* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/7.2/userguide/building_java_projects.html
*/
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
id 'java'
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
testImplementation('org.junit.jupiter:junit-jupiter:5.5.2')
}
application {
// Define the main class for the application.
mainClass = 'JunitPOC.App'
}
test{
useJUnitPlatform()
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}查看依赖项,我可以看到所有依赖项都在测试编译&运行时路径中。

更深入地查看源代码,我发现Intellij并没有正确地为junit.api jar选择源文件,只是为了测试类。我能引用的所有其他类。

有没有人遇到过这个问题?任何帮助都会得到重视。
发布于 2021-09-22 05:55:11
在进入文件>管理IDE设置>恢复默认设置后,我可以让它工作。
https://stackoverflow.com/questions/69251272
复制相似问题