我一直在尝试将服务迁移到 java 9,尽管我可以编译并运行 fat.jar,但我无法在 Intellij 上运行它,原因是库 vertx 的拆分包问题- hk2 和 vertx.jersey,因为两个库具有完全相同的包 com.englishtown.vertx.hk2
我尝试用(修补模块,排除)之类的想法来解决这个问题,但似乎没有任何效果,我不能只排除其中之一,因为两者对于服务运行都是必不可少的。
当 intellij 尝试执行服务时,会发生这种情况
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules vertx.jersey and vertx.hk2 export package com.englishtown.vertx.hk2 to module kryo.serializers
Process finished with exit code 1
原因很清楚
所以我想向遇到此问题的人寻求帮助,您是如何设法使其运行的?
P.S:我向项目所有者提出的问题https://github.com/ef-labs/vertx-hk2/issues/8
最佳答案
我找到了一种方法来解决这个问题,我基本上将具有相同包的两个 jar 合并为一个,pom 看起来非常简单,类似于
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<!-- put your configurations here -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.englishtown.vertx:vertx-hk2</include>
<include>com.englishtown.vertx:vertx-jersey</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
没有理想的解决方案,但它有效,阴影 jar 合并了两个库可以在同一模块中共存的包。
关于java - intellij 上的 vertx-hk2 和 vertx-jersey 拆分包问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50007012/