java 9 module reads package X from A and B

后端 未结 2 1468
终归单人心
终归单人心 2020-12-06 06:16

I am trying to use spring boot with java 9 and gradle. I am unable to run my simple code, I get the below mentioned error :-

Information:java: Errors occurre         


        
相关标签:
2条回答
  • 2020-12-06 06:26

    Excluding the transitive dependency made it work and adjusting the module-info.java too!!!

    compile("org.springframework.boot:spring-boot-starter:1.5.3.RELEASE") {
            exclude group: 'commons-logging', module: 'commons-logging'
        }
        compile("org.springframework.boot:spring-boot-starter-web:1.5.3.RELEASE"){
            exclude group: 'commons-logging', module: 'commons-logging'
        }
    
    0 讨论(0)
  • 2020-12-06 06:39

    According to the Jigsaw specs

    Non-interference — The Java compiler, virtual machine, and run-time system must ensure that modules that contain packages of the same name do not interfere with each other. If two distinct modules contain packages of the same name then, from the perspective of each module, all of the types and members in that package are defined only by that module. Code in that package in one module must not be able to access package-private types or members in that package in the other module.

    This is referred to as split packages in the answer by @Andy here. The solution thereby is to unsplit these packages and make sure that the packages that are included from your modules jcl.over.slf4j and commons.logging are accessed via only one module.


    You can analyze both dependencies spring-boot-starter:1.5.3.RELEASE and spring-boot-starter-web:1.5.3.RELEASE to make sure either of the two modules is included in your project.

    0 讨论(0)
提交回复
热议问题