【发布时间】:2014-11-18 21:59:25
【问题描述】:
我正在使用 Dropwizard 和 Titan DB 开发一个项目。两者都依赖于 Google Guava。一个依赖于版本 15,另一个依赖于 18。此错误发生在运行时:
! java.lang.IllegalAccessError: tried to access method com.google.common.base.Stopwatch.<init>()V from class com.thinkaurelius.titan.graphdb.database.idassigner.StandardIDPool$ID
BlockRunnable
我研究了错误并found 是由泰坦的番石榴引起的 15.0 依赖被 Guava 18.0 驱逐。
我是 Java 和 Gradle 的新手。我正在使用 Gradle 的 java 和 application 插件来构建和运行带有 gradle run 的主类。我该如何解决这个问题?
这是我的build.gradle:
apply plugin: 'java'
apply plugin: 'application'
mainClassName = "com.example.rest.App"
repositories {
mavenCentral()
}
dependencies {
compile (
[group: 'io.dropwizard', name: 'dropwizard-core', version: '0.8.0-rc1'],
[group: 'com.thinkaurelius.titan', name: 'titan-core', version: '0.5.1'],
[group: 'com.thinkaurelius.titan', name: 'titan-berkeleyje', version: '0.5.1'],
[group: 'com.tinkerpop', name: 'frames', version: '2.6.0']
)
testCompile group: 'junit', name: 'junit', version: '3.8.1'
}
run {
if ( project.hasProperty("appArgs") ) {
args Eval.me(appArgs)
}
}
【问题讨论】:
-
如果可能的话,我宁愿不构建用于运行/测试的胖罐子。我目前正在阅读gradle.org/docs/current/userguide/dependency_management.html。
-
你能出示你的
build.gradle文件吗? -
@fge 把它放上来。我阅读的dependency_management.html越多,我似乎就越需要继续阅读该页面。
-
迄今为止,我认为这是我发现的如何处理这个问题的最佳描述:elastic.co/blog/to-shade-or-not-to-shade