当使用 tika-1.4 得到这个:
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/core/DebuggingClassWriter
at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
... 5 more
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.core.DebuggingClassWriter
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
将这两行添加到 BuildConfig.groovy 中:
compile ("org.apache.tika:tika-core:1.4")
compile ("org.apache.tika:tika-parsers:1.4") {excludes "tika-core"}
如果我不排除tika-core
,tika-parsers
我将获得 2 个版本tika-core
(版本 1.0 由vorbis-java-tika
依赖项提取)和tika-core
版本 1.4。
如果我将 tika 版本替换为 1.3,异常就消失了。
更新 1
该解决方案似乎有效:
compile ("org.apache.tika:tika-core:${tikaVersion}")
compile ("org.apache.tika:tika-parsers:${tikaVersion}") { excludes "tika-core", "commons-codec", "commons-logging", "slf4j-api" }