当前位置:   article > 正文

Gradle项目运行报错Could not find method XXX及解决方案_gradle could not find method docker()

gradle could not find method docker()

Could not find method testCompile() for arguments

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.13.1'
}
  • 1
  • 2
  • 3

原因是较新版的gradle将testCompile换成了testImplementation,因此换一下就好:

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.13.1'
  • 1
  • 2

Could not find method compile() for arguments

dependencies {
    compile group: 'commons-io', name: 'commons-io', version: '2.6'
}
  • 1
  • 2
  • 3

有人说报错原因是因为每一个compile声明之间应该用换行符隔开,可以先试试能不能解决问题。
在gradle官网输入关键字:
Gradle官网
在这里插入图片描述

会发现出现这类问题都是这种依赖配置写法在新版本中被移除了。
在这里插入图片描述

根据提示点进去会发现将compile关键字改一下就好:

dependencies {
    implementation group: 'commons-io', name: 'commons-io', version: '2.6'
}
  • 1
  • 2
  • 3

遇到这类问题去官网查比在csdn查更容易解决问题。

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号