0

我一直在尝试将服务迁移到 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

原因很清楚

所以我想问一些有这个问题的人的帮助,你是如何让它运行的?

PS:我对项目所有者的问题https://github.com/ef-labs/vertx-hk2/issues/8

4

1 回答 1

2

我找到了解决这个问题的方法,我基本上将两个具有相同包的罐子合二为一,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 合并了两个库可以在同一个模块中共存的包。

于 2018-04-25T14:00:57.973 回答