5

in java 8 projects you simply add the following dependencys in maven

<dependency>
    <groupId>javax.json</groupId>
    <artifactId>javax.json-api</artifactId>
    <version>1.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>1.1</version>
</dependency>

Using OpenJDK, Eclipse 2018-12
and maven module, it results in getting a error in the module-info.java:

The package javax.json.stream is accessible from more than one module: java.json, org.glassfish.java.json

So in both dependency projects there is a package called javax.json.stream and due to jigsaw module system this is not allowed anymore?

How to fix this?

EDIT:
I updated the maven dependency to 1.1.4 and put them on the classpath. The javax.json-api has a module-info.java file and is working fine, eclipse shows no more errors.
But now the packages of the implementation javax.json (org.glassfish) are not found, resulting in a ClassNotFoundException: org.glassfish.json.JsonProviderImpl

What more can I do?

EDIT:
Its working now, i forgot to generate a module-info.java in this project.

4

1 回答 1

2

所以在两个依赖项目中都有一个名为 javax.json.stream 的包,由于拼图模块系统,这不再被允许了吗?

这仍然是允许的,但是这两个依赖项都在类路径而不是模块路径上得到解决,即在未命名的模块中。

在将库创建为模块化时解决此问题的另一种方法是确保修复导出相同包的下游库,这需要自下而上的迁移,您可能必须等待他们在最新更新中修复它(或检查一个是否已经出来)然后依赖它们。

于 2019-01-14T15:10:33.007 回答