我对Maven相当新,我想将项目从Kryo 2.22更新到3.0.1。在项目中,我有以下依赖。
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
<version>2.22</version>
</dependency>
该项目使用Maven shade插件创建一个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>
但是我无法弄清楚我应该改变什么,除了groupId:<groupId>com.esotericsoftware.kryo</groupId>
如果我将版本号更改为3.0.1则无法找到阴影类(抛出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)
我认为问题在于Kryo 2.22与Kryo 3.0.1有不同的groupId(com.esotericsoftware.kryo),并且Maven无法连接依赖项。我该如何解决这个问题?
答案 0 :(得分:0)
从您链接到的maven repo search,看起来好像是在maven中央存储库中。但是,groupId
在2.2.x和3.x之间发生了变化。
您是否尝试过:
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>3.0.1</version>
</dependency>
即。和你一样,但没有尾随.kryo