Could not find method testCompile() for arguments
错误如下:
A problem occurred evaluating root project ‘gradle-demo’.
Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.12}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
最近在学习gradle,我使用的是ide的gradle创建的java项目,ide的gradle是很老的版本,其build.gradle文件的dependencies默认如下:
dependencies {
// testCompile代表的是依赖范围
testCompile group: 'junit', name: 'junit', version: '4.12'
}
创建完项目之后,我把ide切换到我下载的是最新的gradle7.2,就报了上面那个错误
在最新版本中,testCompile改为了testImplementation,所以找不到testCompile()方法,只要把testCompile改为testImplementation即可
参考gradle官网:https://docs.gradle.org/current/samples/sample_building_java_libraries.html
本文介绍了从旧版Gradle升级到新版过程中遇到的依赖配置问题。由于Gradle版本更新,原有的testCompile配置不再适用,需要替换为testImplementation。文中给出了具体的修改步骤及官方文档链接。
1176

被折叠的 条评论
为什么被折叠?



