简体   繁体   English

java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLoggerContext 不能转换为 org.apache.logging.log4j.core.LoggerContext

[英]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.

相关问题 获取异常org.apache.logging.slf4j.SLF4JLoggerContext无法强制转换为org.apache.logging.log4j.core.LoggerContext - Getting Exception org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext java.lang.ClassCastException:org.slf4j.helpers.NOPLogger无法转换为org.slf4j.spi.LocationAwareLogger - java.lang.ClassCastException: org.slf4j.helpers.NOPLogger cannot be cast to org.slf4j.spi.LocationAwareLogger Sbt test: class org.apache.logging.slf4j.Log4jLogger cannot be cast to class ch.qos.logback.classic.Logger (org.apache.logging.slf4j.Log4jLogger - Sbt test: class org.apache.logging.slf4j.Log4jLogger cannot be cast to class ch.qos.logback.classic.Logger (org.apache.logging.slf4j.Log4jLogger 带有org.apache.logging.log4j.Logger的java.lang.ClassCastException - java.lang.ClassCastException with org.apache.logging.log4j.Logger java.lang.ClassCastException:net.kencochrane.raven.log4j.SentryAppender无法转换为org.apache.log4j.Appender - java.lang.ClassCastException: net.kencochrane.raven.log4j.SentryAppender cannot be cast to org.apache.log4j.Appender 引起:org.apache.logging.log4j.LoggingException:log4j-slf4j-impl 不能与 log4j-to-slf4j 一起出现 - Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j log4j-to-slf4j 没有实现 org.apache.logging.log4j.LogManager - log4j-to-slf4j does not implement org.apache.logging.log4j.LogManager 引起:org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j Issue - Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j Issue java.lang.NoClassDefFoundError:org / apache / log4j / Level - slf4j? - java.lang.NoClassDefFoundError: org/apache/log4j/Level - slf4j? org.slf4j.helpers.NOPLogger无法转换为java.util.logging.Logger - org.slf4j.helpers.NOPLogger cannot be cast to java.util.logging.Logger
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM