接收器类 ch.qos.logback.classic.util.DefaultJoranConfigurator 未定义或继承已解析方法的实现

问题描述 投票:0回答:1

我将

spring hateoas
添加到项目中,但无法启动项目。

我添加了这些库:

    implementation 'com.toedter:spring-hateoas-jsonapi:2.0.1'
    implementation 'org.springframework.boot:spring-boot-starter-hateoas:3.0.2'

我有这个

logback-spring
配置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <springProperty scope="context" name="filename" source="app.logging.filename" defaultValue="application"/>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{yyyy.MM.dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{36}:%L) - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="DAILY_ROLLING_FILE_APPENDER_JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>logs/${filename}.json</file>

        <!-- TBD: This encoder differs from the one used in the Dashboard project in order to generate JSON output -->
        <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>logs/archived/${filename}-%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
            <totalSizeCap>100MB</totalSizeCap>
        </rollingPolicy>
    </appender>

    <!-- config for STDOUT and SAVE-TO-FILE -->
    <springProfile name="local">
        <root level="info">
            <appender-ref ref="DAILY_ROLLING_FILE_APPENDER_JSON" />
            <appender-ref ref="STDOUT" />
        </root>
    </springProfile>
    <springProfile name="staging">
        <root level="info">
            <appender-ref ref="STDOUT" />
            <appender-ref ref="DAILY_ROLLING_FILE_APPENDER_JSON" />
        </root>
    </springProfile>
    <springProfile name="integration">
        <root level="info">
            <appender-ref ref="DAILY_ROLLING_FILE_APPENDER_JSON" />
        </root>
    </springProfile>
    <springProfile name="production">
        <root level="info">
            <appender-ref ref="DAILY_ROLLING_FILE_APPENDER_JSON" />
        </root>
    </springProfile>
</configuration>

我有这个 logback 依赖项:

implementation "net.logstash.logback:logstash-logback-encoder:7.0.1

当我运行 spring-boot 项目时:

Exception in thread "main" java.lang.AbstractMethodError: Receiver class ch.qos.logback.classic.util.DefaultJoranConfigurator does not define or inherit an implementation of the resolved method 'abstract void configure(ch.qos.logback.classic.LoggerContext)' of interface ch.qos.logback.classic.spi.Configurator.
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:140)
    at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
    at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
    at org.apache.commons.logging.LogAdapter$Slf4jAdapter.createLocationAwareLog(LogAdapter.java:130)
    at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:91)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
    at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:174)
spring-boot logback spring-hateoas hateoas
1个回答
3
投票

我遇到了这个问题:

implementation group: "ch.qos.logback", name:"logback-classic", version:"1.2.3"

如果我将其更改为:

,它就会起作用
implementation group: "ch.qos.logback", name:"logback-classic", version:"1.4.7"
© www.soinside.com 2019 - 2024. All rights reserved.