我试图通过API来创建拼写检查程序,这里是我的代码java.lang.ClassCastException:org.apache.logging.slf4j.SLF4JLoggerContext不能转换到org.apache.logging.log4j.core.LoggerContext
SpellCheck.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());
}
}
依赖
错误我它运行后得到:
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
这似乎是'org.xeustechnologies.googleapi.spelling.SpellChecker' API中的一个错误。 – paper1111