I get tons of "split package" errors, when I introduce java 9 modules in my SpringBoot code. They are everywhere, eg.:
Error:java: the unnamed module reads package org.bson.types from both bson and mongodb.driver
Error:java: the unnamed module reads package org.bson.io from both bson and mongodb.driver
Error:java: the unnamed module reads package org.bson from both bson and mongodb.driver
Error:java: the unnamed module reads package com.mongodb.client.model from both mongodb.driver.core and mongodb.driver
Error:java: the unnamed module reads package com.mongodb.client from both mongodb.driver.core and mongodb.driver
Error:java: the unnamed module reads package com.mongodb from both mongodb.driver.core and mongodb.driver
Error:java: the unnamed module reads package org.aopalliance.aop from both aopalliance.repackaged and spring.aop
...
I have tried with lots of different releases, including 1.5.3.RELEASE
, 2.0.0.M5
and 2.0.0.BUILD-SNAPSHOT
.
The problems seem to come when maven takes all dependencies and add them as "Automatic Modules" on the module-path. Many of the dependencies have duplicated packages, which is not allowed in java 9. An examples of a bad dependency is spring.aop:5.0.1.BUILD-SNAPSHOT
that obviously packages org.aopalliance.aop
.
It is SpringBoot that defines all the dependencies. I even tried to use a vanilla project from spring initializr, adding only:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Furthermore, I added a module-info.java to make the demo code java 9 compliant:
├── src
│ ├── main
│ │ ├── java
│ │ │ ├── com
│ │ │ │ └── example
│ │ │ │ └── demo
│ │ │ │ └── DemoApplication.java
│ │ │ └── module-info.java
│
This doesn't compile.
Question: Does anyone have a working example of a SpringBoot project, where the code is organised in java 9 modules?