Could not find method compile

Could not find method compile,第1张

gradle升级到7.3.3时,编译出现错误如下:

* What went wrong:
A problem occurred evaluating root project 'test-common-lib'.
> Could not find method compile() for arguments [com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20211018.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

按照网上的说法添加java-library如下,依然不可以:

plugins {
    id 'java-library'
    id 'java'
    id 'maven-publish'
}

后来返现错误是找不到compile方法,于是就把compile改为implementation如下:

dependencies {
    implementation  'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20211018.2'
    implementation  'com.google.guava:guava:30.0-jre'
    implementation  'com.github.jknack:handlebars:4.3.0'
    testImplementation 'junit:junit:4.13.1'
}

问题就解决了。

 究其原因,根据Gradle的官方文档:The Java Plugin,显示的依赖的配置如下:

 可以看到compile已经不在列表里了,它已经被implementation所取代。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/731229.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存