栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.11}]问题的解决

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.11}]问题的解决

在跑outtertune的项目,遇见了一个错误。 

 错误代码:

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    runtime fileTree(dir: 'libs', include: '*.jar')
    compile group: 'net.sourceforge.collections', name: 'collections-generic', version: '4.01'
    compile group: 'commons-lang', name: 'commons-lang', version: '2.6'

新版本中,testCompile改为了testImplementation,所以报错,找不到testCompile()方法,把testCompile改为testImplementation即可

老版本的gradle已经对一些配置名字进行了修改

使用implementation、api, 代替compile ,

testImplementation 代替testCompile

androidTestImplementation 代替 androidTestCompile

正确方式:

    testImplementation group: 'junit', name: 'junit', version: '4.11'

拓展知识:build.gradle的步骤以及原因:

1、将java库插件应用于API和实现分离。

2、使用Maven Central解析依赖项。

3、使用JUnitJupiter进行测试。

4、这个依赖项被导出到使用者,也就是说在他们的编译类路径上找到。

5、此依赖关系在内部使用,不会在使用者自己的编译类路径上公开给使用者。


//https://docs.gradle.org/current/samples/sample_building_java_libraries.html


Apply the java-library plugin for API and implementation separation.
Use Maven Central for resolving dependencies.
Use JUnit Jupiter for testing.
This dependency is exported to consumers, that is to say found on their compile classpath.
This dependency is used internally, and not exposed to consumers on their own compile classpath.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/682861.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号