Error: package xxx is declared in module java.base, which does not export it
Symptom
When JDK 11 or a later version is used, the following error information is displayed:
java: package xxx is not visible (package xxx is declared in module java.base, which does not export it)
Possible Causes
Startup parameters are not added to the pom.xml or build.gradle file.
Troubleshooting Procedure
Add compilation startup parameters to the pom.xml or build.gradle file.
For example, add compilation startup parameters to the pom.xml file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <build> <plugins> <plugin> <!-- Compilation plugin --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <encoding>${project.build.sourceEncoding}</encoding> <compilerArgs> <arg>--add-exports</arg> <arg>java.base/sun.util.calendar=ALL-UNNAMED</arg> </compilerArgs> </configuration> </plugin> </plugins> </build> |
Parent topic: FAQs