Just came into contact with the module system of jdk 11, so how to deal with module-info.java?

I have an old SpringBoot project, which now runs on jdk11 and works normally, but will report the following error when the project starts:

  stackoverflow  found that module-info.java can be used to solve the 
problem. Now that I create a module-info.java file, do all modules need their own requires or open ? Even if I know what needs to be imported (and I don"t know what to import), it"s too much and unfriendly. Do you have any good ideas?

Project configuration:
SpringBoot: 2.1.1.RELEASE
Gradle: 5.1.1
Jdk: 11

Apr.16,2022

  • if you want to use module-info.java, you probably have to transform it to support JPMS as a whole.
  • because module java.base does not export jdk.internal.misc to unnamed module see this error report. Just give the open of jdk.internal.misc to unnamed module. You can add the compilerArgs parameter to maven compiler plugin
<compilerArgs>
    <arg>-J--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED</arg>        
</compilerArgs>

have you solved it, jdk12? I have also encountered this problem. How to solve it?

Menu