I get tons of "split package" errors when I inject java 9 modules into my SpringBoot code. They are everywhere, for example:
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 tried with many different releases, including 1.5.3.RELEASE , 2.0.0.M5 and 2.0.0.BUILD-SNAPSHOT .
Problems arise when maven accepts all the dependencies and adds them as "Automatic modules" on the way to the module. Many of the dependencies have duplicate packages that are not allowed in java 9. Examples of bad dependencies are spring.aop:5.0.1.BUILD-SNAPSHOT , which are obviously org.aopalliance.aop packages.
It is SpringBoot that defines all the dependencies. I even tried using the spring initializr vanilla project, 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>
In addition, I added module-info.java to make java 9 demo code compatible:
├── src │ ├── main │ │ ├── java │ │ │ ├── com │ │ │ │ └── example │ │ │ │ └── demo │ │ │ │ └── DemoApplication.java │ │ │ └── module-info.java │
This does not compile.
Question: Does anyone have a working example of a SpringBoot project where the code is organized in java 9 modules?
source share