jdk.internal.reflect包不可见java
java9模块化以后,java.base只把jdk.internal.reflect暴露给了少数几个内部包而没有向当前模块暴露。apache
alt+enter IDEA会自动提示解决方案,它的解决方案只针对.idea/compiler.xml。即使直接运行程序不报错,在执行mvn compile时也会报错,说jdk.internal.reflect不可见。maven
<component name="JavacSettings"> <option name="ADDITIONAL_OPTIONS_OVERRIDE"> <module name="hanlp" options="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED,hanlp" /> </option> </component>
须要进一步更改compiler插件的命令行参数ide
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>12</source> <target>12</target> <encoding>utf-8</encoding> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> <compilerArgument> --add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED,hanlp </compilerArgument> </configuration> </plugin>