IDEA java: package is not visible
Java IDEA 大约 1337 字错误信息
java: package jdk.nashorn.internal.runtime.regexp.joni.constants is not visible
(package jdk.nashorn.internal.runtime.regexp.joni.constants is declared in module jdk.scripting.nashorn, which does not export it)
错误原因
Java9
之后才用模块化方式分包,常用的module
已经export
了,但对于不常用的、下一个版本要删除的module
、或者不愿意让你使用的,你却要使用。则必须人为export
。
解决方法
方法一
编写module-info.java
文件,export
需要用到的模块。
方法二
IDEA
中,对于import
包报错的,可以使用Alt
+Enter
快捷键,提示Add '' to module compiler options
将指定的包加入到编译时期。
可以在Java Compiler
中的Javac Options
栏目下的Override compiler paramenters per-module:
中看到添加的信息。
Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler
也可以在.idea
文件夹下的compiler.xml
文件中查看:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="USE_RELEASE_OPTION" value="false" />
<bytecodeTargetLevel target="11" />
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="TestDemo" options="--add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp.joni.constants=ALL-UNNAMED --add-exports jdk.scripting.nashorn/jdk.nashorn.tools=ALL-UNNAMED --add-exports java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED" />
</option>
</component>
</project>
阅读 1357 · 发布于 2021-07-07
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
PostgreSQL 查看时区阅读 4394
-
MySQL 内置函数之字符串函数阅读 1561
-
软考-系统架构设计师:云计算阅读 903
-
MySQL 全文检索设置停止词阅读 1505
-
Linux xxx is not in the sudoers file.This incident will be reported阅读 1552
-
Linux tcpdump: no suitable device found阅读 1403
-
Spring 组件的注册时机阅读 317
-
Spring Boot JdbcTemplate 插入枚举类型阅读 2793
-
Nginx 解决前端 CORS 跨域问题阅读 6403
-
Spring 事务原理阅读 360