我目前正在尝试使用 log4j/slf4j 和 java 11 构建一个应用程序,但我在运行时遇到这个问题:
2018-12-10 22:09:27,225 main INFO Cannot initialize scripting support because this JRE does not support it. java.lang.NoClassDefFoundError: javax/script/ScriptEngineManager
at [email protected]/org.apache.logging.log4j.core.script.ScriptManager.<init>(ScriptManager.java:69)
at [email protected]/org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:216)
at [email protected]/org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
at [email protected]/org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
at [email protected]/org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
at [email protected]/org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
at [email protected]/org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
at [email protected]/org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at [email protected]/org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j/org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j/org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
at [email protected]/org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:49)
at org.apache.logging.log4j/org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at [email protected]/org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j/org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:355)
at org.slf4j/org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:380)
at fr.mrcraftcod.nameascreated/fr.mrcraftcod.nameascreated.NameAsCreated.<clinit>(NameAsCreated.java:39)
Caused by: java.lang.ClassNotFoundException: javax.script.ScriptEngineManager
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 17 more
此代码的起源是我的记录器的初始化:
private static final Logger LOGGER = LoggerFactory.getLogger(NameAsCreated.class);
我依赖于:
我使用的是 Java 版本的 OSX Mojave:
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment AdoptOpenJDK (build 11+28-201810021910)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11+28-201810021910, mixed mode)
有人知道我做错了什么以及如何解决这个问题吗?