问题
Failed to auto configure default logger context
Reported exception:
ch.qos.logback.core.joran.spi.JoranException: Parser configuration error occurred
at ch.qos.logback.core.joran.event.SaxEventRecorder.buildSaxParser(SaxEventRecorder.java:89)
at ch.qos.logback.core.joran.event.SaxEventRecorder.recordEvents(SaxEventRecorder.java:57)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:151)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:64)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:134)
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.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
法1: SAX feature 问题解决方法
引入的依赖 javax.xml.parsers.SAXParserFactory 有多个实现。使用的不支持 logback 的特性。设置 SAXParserFactory 为支持 logback 特性的实现类。
System.setProperty("javax.xml.parsers.SAXParserFactory","com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
法2: 排除引入的其他的 xml parser
比如排除 oracle database xml 里的 xmlparser
gradle 配置如下:
configurations {
runtime.exclude group: "com.oracle.database.xml", module: "xmlparserv2"
compile.exclude group: "com.oracle.database.xml", module: "xmlparserv2"
}
Refs
-
https://github.com/spring-projects/spring-boot/issues/28989#issuecomment-991251061
-
https://stackoverflow.com/a/70327292/9112817