![](/img/trans.png)
[英]Gradle build from command line fails with an exception, “Could not initialize class org.codehaus.groovy.runtime.InvokerHelper”
[英]Gradle : Could not find org.codehaus.groovy:groovy:1.0.0
我正在使用gradle編譯我的Groovy和Java代碼。 今天,我更新了groovy 2.5.4並將gradle升級到了版本5。
gradle run
命令現在失敗,並顯示此錯誤消息。
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileGroovy'. > Could not resolve all files for configuration ':detachedConfiguration1'. > Could not find org.codehaus.groovy:groovy:1.0.0. Searched in the following locations: - https://jcenter.bintray.com/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.pom - https://jcenter.bintray.com/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.jar - http://repository.apache.org/snapshots/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.pom - http://repository.apache.org/snapshots/org/codehaus/groovy/groovy/1.0.0/groovy-1.0.0.jar Required by: project : * Try:
這是build.gradle文件。
plugins {
id 'groovy'
id 'application'
}
repositories {
jcenter()
maven {
url "http://repository.apache.org/snapshots/"
}
}
dependencies {
// Use the latest Groovy version for building this library
implementation 'org.codehaus.groovy:groovy-all:2.5.4'
compile group: 'commons-cli', name: 'commons-cli', version: '1.4'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.6.1'
compile group: 'org.apache.directory', name: 'groovyldap', version: '0.1-SNAPSHOT'
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
// https://mvnrepository.com/artifact/org.apache.directory.shared/shared-ldif
compile group: 'org.apache.directory.shared', name: 'shared-ldif', version: '0.9.19'
// https://mvnrepository.com/artifact/org.apache.directory.api/api-ldap-model
compile group: 'org.apache.directory.api', name: 'api-ldap-model', version: '1.0.0-M15'
// https://mvnrepository.com/artifact/com.opencsv/opencsv
compile group: 'com.opencsv', name: 'opencsv', version: '4.0'
// https://mvnrepository.com/artifact/org.jsoup/jsoup
compile group: 'org.jsoup', name: 'jsoup', version: '1.11.2'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.11'
// https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
compile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.4.0.jre8'
// https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds
compile group: 'net.sourceforge.jtds', name: 'jtds', version: '1.3.1'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
// https://mvnrepository.com/artifact/org.yaml/snakeyaml
compile group: 'org.yaml', name: 'snakeyaml', version: '1.21'
// https://mvnrepository.com/artifact/com.rubiconproject.oss/jchronic
compile group: 'com.rubiconproject.oss', name: 'jchronic', version: '0.2.8'
compile group: 'io.github.http-builder-ng', name: 'http-builder-ng-core', version: '1.0.3'
// Use the awesome Spock testing and specification framework
testImplementation 'org.spockframework:spock-core:1.2-groovy-2.5'
}
// Define the main class for the application
mainClassName = 'ssl.test.App'
對解決此錯誤消息有幫助嗎?
謝謝SR
您可以將groovyldap
依賴項聲明替換為以下內容(如@ paul-king在評論中所述):
compile(group: 'org.apache.directory', name: 'groovyldap', version: '0.1-SNAPSHOT') {
exclude group: 'groovy', module: 'groovy'
}
這至少將幫助您擺脫依賴性解析錯誤。
我不知道您的groovyldap
依賴項是否仍然可以在Groovy 2.5.4中使用,但是絕對值得一試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.