[英]java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext
I'm trying to create SpellChecker program through api, here is my code我正在尝试通过 api 创建 SpellChecker 程序,这是我的代码
SpellCheck.java拼写检查.java
package com.spell;
import org.xeustechnologies.googleapi.spelling.SpellChecker;
import org.xeustechnologies.googleapi.spelling.SpellCorrection;
import org.xeustechnologies.googleapi.spelling.SpellResponse;
public class SpellCheck {
public static void main(String[] args)
{
SpellChecker checker = new SpellChecker();
SpellResponse spellResponse = checker.check( "helloo worlrd" );
for( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getValue() );
}
}
Dependencies依赖项
Error I got after running it:运行后出现的错误:
Exception in thread "main" java.lang.ExceptionInInitializerError at com.spell.SpellCheck.main(SpellCheck.java:12) Caused by: java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59) at org.apache.log4j.Logger.getLogger(Logger.java:41) at org.xeustechnologies.googleapi.spelling.SpellChecker.(SpellChecker.java:50) ... 1 more com.spell.SpellCheck.main(SpellCheck.java:12) 处的线程“main”java.lang.ExceptionInInitializerError 中的异常原因:java.lang.ClassCastException:org.apache.logging.slf4j.SLF4JLoggerContext 无法转换为 org。 org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59) 上 org.xeustechnologies 上 org.apache.log4j.Logger.getLogger(Logger.java:41) 上的 apache.logging.log4j.core.LoggerContext。 googleapi.spelling.SpellChecker.(SpellChecker.java:50) ... 还有 1 个
It looks like org.xeustechnologies.google.api.spelling.SpellChecker
uses log4j and you are using slf4j.看起来org.xeustechnologies.google.api.spelling.SpellChecker
使用 log4j 而您使用的是 slf4j。 Try adding log4j-over-slf4j to the classpath to bridge log4 to use slf4j.尝试将log4j-over-slf4j添加到类路径以桥接 log4 以使用 slf4j。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.