我对Maven相当陌生,我想将一个项目从Kryo2.22更新到3.0.1。在这个项目中,我有以下的依赖项。
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
<version>2.22</version>
</dependency>
该项目使用Maven树荫插件创建一个jar文件:
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>shade-gremlin-groovy</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<!-- As of Kryo 2.22, this artifact includes both minlog and reflectasm -->
<!-- If we upgrade to later a Kryo version, we may have to add includes
for minlog and reflectasm (this is true of 2.24.0, not sure about 3) -->
<include>com.esotericsoftware.kryo:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>reflectasm-1.07-shaded.jar</exclude>
<exclude>minlog-1.2.jar</exclude>
<exclude>objenesis-1.2.jar</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.esotericsoftware.kryo</pattern>
<shadedPattern>com.thinkaurelius.shaded.kryo_2_22</shadedPattern>
</relocation>
<relocation>
<pattern>com.esotericsoftware.minlog</pattern>
<shadedPattern>com.thinkaurelius.shaded.minlog_1_2</shadedPattern>
</relocation>
<relocation>
<pattern>com.esotericsoftware.reflectasm</pattern>
<shadedPattern>com.thinkaurelius.shaded.reflectasm_1_07</shadedPattern>
</relocation>
<relocation>
<pattern>com.esotericsoftware.shaded.org.objenesis</pattern>
<shadedPattern>com.thinkaurelius.shaded.objenesis_1_2</shadedPattern>
</relocation>
</relocations>
<!-- false below means the shade plugin overwrites the main project artifact (the one with no classifier).
false does *not* actually detach the main artifact, despite what the option name suggests. -->
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>false</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
但是,除了将版本号更改为3.0.1外,我无法计算应该更改什么( groupId为:<groupId>com.esotericsoftware.kryo</groupId>
),它找不到阴影类(抛出ClassNotfound异常:
java.lang.NoClassDefFoundError: com/thinkaurelius/shaded/kryo_3_0_1/kryo/Serializer
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.thinkaurelius.titan.graphdb.database.serialize.kryo.KryoSerializer.<init>(KryoSerializer.java:71)
at com.thinkaurelius.titan.graphdb.database.serialize.StandardSerializer.<init>(StandardSerializer.java:29)
at com.thinkaurelius.titan.graphdb.database.serialize.StandardSerializer.<init>(StandardSerializer.java:41)
at com.thinkaurelius.titan.diskstorage.configuration.backend.KCVSConfiguration.<init>(KCVSConfiguration.java:69)
at com.thinkaurelius.titan.diskstorage.configuration.backend.KCVSConfiguration.<init>(KCVSConfiguration.java:57)
at com.thinkaurelius.titan.diskstorage.configuration.KCVSConfigTest.getConfig(KCVSConfigTest.java:31)
我认为问题在于Kryo2.22与Kryo3.0.1有不同的groupId (com.esotericsoftware.kryo),而且Maven无法连接该依赖项。我该怎么解决这个问题?
发布于 2015-05-01 13:08:25
在maven阴影插件中,出现了以下一行:
<include>com.esotericsoftware.kryo:*</include>
必须改为:
<include>com.esotericsoftware:*</include>
因为groupId是不同的。所以问题是依赖的错配。
https://stackoverflow.com/questions/29987096
复制相似问题