[spring-projects/spring-boot]Spring Boot 3 logback smtp 附加程序不兼容

2024-05-08 479 views
6

各位,

我使用 Logback 和 SMTP 附加程序经历了 Spring 的奇怪行为。看来,最新的 Spring 版本和 Logback SMTP 附加程序之间不兼容。

登录文件:

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
https://howtodoinjava.com/spring-boot2/logging/profile-specific-logging/
https://howtodoinjava.com/spring-boot2/logging/profile-specific-logging/
-->
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />

    <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
        <smtpHost>...</smtpHost>
        <to>...</to>
        <from>...</from>
        <subject>...</subject>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%date %-5level %logger{35} - %message%n</pattern>
        </layout>    
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>   
    </appender>                                    

    <root level="INFO">
          <appender-ref ref="EMAIL" />
    </root>

</configuration>

logback smtp 的依赖项:

  <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
  </dependency> 

例外:

--- spring-boot-maven-plugin:3.1.2:run (default-cli) @ vsm-backend ---
Attaching agents: []
Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@6a7b85ad - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@6a7b85ad - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.reportConfigurationErrorsIfNecessary(LogbackLoggingSystem.java:260)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:247)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:187)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:356)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at hu.wfs.vsm.ManagerApplication.main(ManagerApplication.java:27)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@6a7b85ad - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@6a7b85ad - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:347)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:356)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at hu.wfs.vsm.ManagerApplication.main(ManagerApplication.java:27)
    ... 5 more
Caused by: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@6a7b85ad - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@6a7b85ad - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.reportConfigurationErrorsIfNecessary(LogbackLoggingSystem.java:260)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:247)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:187)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
    ... 24 more

回答

5

没有额外依赖的异常:

--- spring-boot-maven-plugin:3.1.2:run (default-cli) @ vsm-backend ---
Attaching agents: []
Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@376c02bf - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@376c02bf - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.reportConfigurationErrorsIfNecessary(LogbackLoggingSystem.java:260)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:247)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:187)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:356)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at hu.wfs.vsm.ManagerApplication.main(ManagerApplication.java:27)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@376c02bf - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@376c02bf - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:347)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:356)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at hu.wfs.vsm.ManagerApplication.main(ManagerApplication.java:27)
    ... 5 more
Caused by: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@376c02bf - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.AppenderModelHandler - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.model.processor.DefaultProcessor@376c02bf - Failed to traverse model appender ch.qos.logback.core.model.processor.ModelHandlerException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.reportConfigurationErrorsIfNecessary(LogbackLoggingSystem.java:260)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:247)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:187)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
    ... 24 more
2

我不明白,有类文件:

图像

4

依赖项:

hu.wfs.vau:vsm-backend:jar:0.0.11-SNAPSHOT
+- org.springframework.boot:spring-boot-starter-web:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-starter:jar:3.1.2:compile
|  |  +- org.springframework.boot:spring-boot-starter-logging:jar:3.1.2:compile
|  |  |  +- ch.qos.logback:logback-classic:jar:1.4.8:compile
|  |  |  |  \- ch.qos.logback:logback-core:jar:1.4.8:compile
|  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.20.0:compile
|  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.20.0:compile
|  |  |  \- org.slf4j:jul-to-slf4j:jar:2.0.7:compile
|  |  +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile
|  |  \- org.yaml:snakeyaml:jar:1.33:compile
|  +- org.springframework.boot:spring-boot-starter-json:jar:3.1.2:compile
|  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.15.2:compile
|  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.15.2:compile
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:3.1.2:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:10.1.11:compile
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:10.1.11:compile
|  +- org.springframework:spring-web:jar:6.0.11:compile
|  |  \- org.springframework:spring-beans:jar:6.0.11:compile
|  \- org.springframework:spring-webmvc:jar:6.0.11:compile
|     +- org.springframework:spring-context:jar:6.0.11:compile
|     \- org.springframework:spring-expression:jar:6.0.11:compile
+- org.springframework.boot:spring-boot-devtools:jar:3.1.2:runtime
|  +- org.springframework.boot:spring-boot:jar:3.1.2:compile
|  \- org.springframework.boot:spring-boot-autoconfigure:jar:3.1.2:compile
+- org.springframework.boot:spring-boot-starter-test:jar:3.1.2:test
|  +- org.springframework.boot:spring-boot-test:jar:3.1.2:test
|  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:3.1.2:test
|  +- com.jayway.jsonpath:json-path:jar:2.8.0:test
|  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0:compile
|  |  \- jakarta.activation:jakarta.activation-api:jar:2.1.2:compile
|  +- net.minidev:json-smart:jar:2.4.11:test
|  |  \- net.minidev:accessors-smart:jar:2.4.11:test
|  |     \- org.ow2.asm:asm:jar:9.3:compile
|  +- org.assertj:assertj-core:jar:3.24.2:test
|  |  \- net.bytebuddy:byte-buddy:jar:1.14.5:runtime
|  +- org.hamcrest:hamcrest:jar:2.2:test
|  +- org.junit.jupiter:junit-jupiter:jar:5.9.3:test
|  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.9.3:test
|  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
|  |  |  +- org.junit.platform:junit-platform-commons:jar:1.9.3:test
|  |  |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
|  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.9.3:test
|  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.9.3:test
|  |     \- org.junit.platform:junit-platform-engine:jar:1.9.3:test
|  +- org.mockito:mockito-core:jar:5.3.1:test
|  |  +- net.bytebuddy:byte-buddy-agent:jar:1.14.5:test
|  |  \- org.objenesis:objenesis:jar:3.3:test
|  +- org.mockito:mockito-junit-jupiter:jar:5.3.1:test
|  +- org.skyscreamer:jsonassert:jar:1.5.1:test
|  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
|  +- org.springframework:spring-core:jar:6.0.11:compile
|  |  \- org.springframework:spring-jcl:jar:6.0.11:compile
|  +- org.springframework:spring-test:jar:6.0.11:test
|  \- org.xmlunit:xmlunit-core:jar:2.9.1:test
+- org.slf4j:log4j-over-slf4j:jar:2.0.7:compile
|  \- org.slf4j:slf4j-api:jar:2.0.7:compile
+- net.bull.javamelody:javamelody-spring-boot-starter:jar:2.0.0:compile
|  +- net.bull.javamelody:javamelody-core:jar:2.0.0:compile
|  |  \- org.jrobin:jrobin:jar:1.5.9:compile
|  \- org.springframework.boot:spring-boot-starter-aop:jar:3.1.2:compile
|     \- org.aspectj:aspectjweaver:jar:1.9.19:compile
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-starter-jdbc:jar:3.1.2:compile
|  |  +- com.zaxxer:HikariCP:jar:5.0.1:compile
|  |  \- org.springframework:spring-jdbc:jar:6.0.11:compile
|  +- org.hibernate.orm:hibernate-core:jar:6.2.6.Final:compile
|  |  +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0:compile
|  |  +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1:compile
|  |  +- org.jboss.logging:jboss-logging:jar:3.5.3.Final:compile
|  |  +- org.hibernate.common:hibernate-commons-annotations:jar:6.0.6.Final:runtime
|  |  +- io.smallrye:jandex:jar:3.0.5:runtime
|  |  +- com.fasterxml:classmate:jar:1.5.1:compile
|  |  +- org.glassfish.jaxb:jaxb-runtime:jar:4.0.3:compile
|  |  |  \- org.glassfish.jaxb:jaxb-core:jar:4.0.3:compile
|  |  |     +- org.eclipse.angus:angus-activation:jar:2.0.1:runtime
|  |  |     +- org.glassfish.jaxb:txw2:jar:4.0.3:compile
|  |  |     \- com.sun.istack:istack-commons-runtime:jar:4.1.2:compile
|  |  +- jakarta.inject:jakarta.inject-api:jar:2.0.1:runtime
|  |  \- org.antlr:antlr4-runtime:jar:4.10.1:compile
|  +- org.springframework.data:spring-data-jpa:jar:3.1.2:compile
|  |  +- org.springframework.data:spring-data-commons:jar:3.1.2:compile
|  |  +- org.springframework:spring-orm:jar:6.0.11:compile
|  |  \- org.springframework:spring-tx:jar:6.0.11:compile
|  \- org.springframework:spring-aspects:jar:6.0.11:compile
+- org.springframework.boot:spring-boot-starter-security:jar:3.1.2:compile
|  +- org.springframework:spring-aop:jar:6.0.11:compile
|  +- org.springframework.security:spring-security-config:jar:6.1.2:compile
|  \- org.springframework.security:spring-security-web:jar:6.1.2:compile
+- org.springframework.boot:spring-boot-starter-validation:jar:3.1.2:compile
|  +- org.apache.tomcat.embed:tomcat-embed-el:jar:10.1.11:compile
|  \- org.hibernate.validator:hibernate-validator:jar:8.0.1.Final:compile
|     \- jakarta.validation:jakarta.validation-api:jar:3.0.2:compile
+- org.springframework.security:spring-security-test:jar:6.1.2:test
|  \- org.springframework.security:spring-security-core:jar:6.1.2:compile
|     \- org.springframework.security:spring-security-crypto:jar:6.1.2:compile
+- org.springframework.boot:spring-boot-starter-oauth2-resource-server:jar:3.1.2:compile
|  +- org.springframework.security:spring-security-oauth2-resource-server:jar:6.1.2:compile
|  |  \- org.springframework.security:spring-security-oauth2-core:jar:6.1.2:compile
|  \- org.springframework.security:spring-security-oauth2-jose:jar:6.1.2:compile
|     \- com.nimbusds:nimbus-jose-jwt:jar:9.31:compile
|        \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
+- org.springframework.boot:spring-boot-starter-thymeleaf:jar:3.1.2:compile
|  \- org.thymeleaf:thymeleaf-spring6:jar:3.1.1.RELEASE:compile
|     \- org.thymeleaf:thymeleaf:jar:3.1.1.RELEASE:compile
|        +- org.attoparser:attoparser:jar:2.0.6.RELEASE:compile
|        \- org.unbescape:unbescape:jar:1.1.6.RELEASE:compile
+- org.thymeleaf.extras:thymeleaf-extras-springsecurity6:jar:3.1.1.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-actuator:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:3.1.2:compile
|  |  \- org.springframework.boot:spring-boot-actuator:jar:3.1.2:compile
|  +- io.micrometer:micrometer-observation:jar:1.11.2:compile
|  |  \- io.micrometer:micrometer-commons:jar:1.11.2:compile
|  \- io.micrometer:micrometer-core:jar:1.11.2:compile
|     +- org.hdrhistogram:HdrHistogram:jar:2.1.12:runtime
|     \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
+- com.sun.mail:javax.mail:jar:1.6.2:compile
|  \- javax.activation:activation:jar:1.1:compile
+- org.passay:passay:jar:1.6.3:compile
+- com.sun.activation:jakarta.activation:jar:2.0.0:compile
+- hu.wfs.lib.halozat:WFSLib_Halozat:jar:2.7.0:compile
|  +- hu.wfs.lib.biztonsag:WFSLib_Biztonsag:jar:2.5.3:compile
|  |  +- hu.wfs.lib.altalanos:WFSLib_Altalanos:jar:2.7.2:compile
|  |  |  +- org.apache.velocity:velocity:jar:1.5:compile
|  |  |  |  +- commons-collections:commons-collections:jar:3.1:compile
|  |  |  |  +- commons-lang:commons-lang:jar:2.1:compile
|  |  |  |  \- oro:oro:jar:2.0.8:compile
|  |  |  +- net.sourceforge.jexcelapi:jxl:jar:2.6.12:compile
|  |  |  +- org.apache.poi:poi:jar:3.17:compile
|  |  |  |  \- org.apache.commons:commons-collections4:jar:4.1:compile
|  |  |  +- org.apache.poi:poi-ooxml:jar:3.17:compile
|  |  |  |  +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
|  |  |  |  |  \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
|  |  |  |  |     \- stax:stax-api:jar:1.0.1:compile
|  |  |  |  \- com.github.virtuald:curvesapi:jar:1.04:compile
|  |  |  +- com.sun.xml.bind:jaxb-core:jar:4.0.3:compile
|  |  |  \- com.sun.xml.bind:jaxb-impl:jar:4.0.3:compile
|  |  +- kulsojar.bcprov_jdk16_jeloletlen_1_43:bcprov_jdk16_jeloletlen_1_43:jar:1.0.0:compile
|  |  +- ch.ethz.ganymed:ganymed-ssh2:jar:build210:compile
|  |  +- J2SSHCommon:J2SSHCommon:jar:0.2.9-patched:system
|  |  +- J2SSHCore:J2SSHCore:jar:0.2.9-patched:system
|  |  +- commons-httpclient:commons-httpclient:jar:3.0.1:compile
|  |  \- commons-logging:commons-logging:jar:1.0.4:compile
|  +- javax.mail:javax.mail-api:jar:1.6.2:compile
|  +- javax.xml.ws:jaxws-api:jar:2.3.1:compile
|  |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
|  |  |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
|  |  +- javax.xml.soap:javax.xml.soap-api:jar:1.4.0:compile
|  |  \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
|  \- org.jsoup:jsoup:jar:1.13.1:compile
+- org.projectlombok:lombok:jar:1.18.28:compile
+- org.keycloak:keycloak-admin-client:jar:21.0.1:compile
|  +- org.keycloak:keycloak-core:jar:21.0.1:compile
|  +- org.keycloak:keycloak-common:jar:21.0.1:compile
|  +- org.jboss.resteasy:resteasy-client:jar:4.7.7.Final:compile
|  |  +- org.jboss.resteasy:resteasy-client-api:jar:4.7.7.Final:compile
|  |  +- org.jboss.resteasy:resteasy-core-spi:jar:4.7.7.Final:compile
|  |  |  \- org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec:jar:2.0.1.Final:compile
|  |  +- org.jboss.resteasy:resteasy-core:jar:4.7.7.Final:compile
|  |  |  +- com.ibm.async:asyncutil:jar:0.1.0:compile
|  |  |  \- io.smallrye.config:smallrye-config:jar:2.3.0:compile
|  |  |     \- io.smallrye.config:smallrye-config-core:jar:2.3.0:compile
|  |  |        +- org.eclipse.microprofile.config:microprofile-config-api:jar:2.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-annotation:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-expression:jar:1.6.0:compile
|  |  |        |  \- io.smallrye.common:smallrye-common-function:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-constraint:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-classloader:jar:1.6.0:compile
|  |  |        \- io.smallrye.config:smallrye-config-common:jar:2.3.0:compile
|  |  +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
|  |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.16:compile
|  |  +- commons-codec:commons-codec:jar:1.15:compile
|  |  +- commons-io:commons-io:jar:2.9.0:compile
|  |  +- org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar:2.0.1.Final:compile
|  |  \- org.reactivestreams:reactive-streams:jar:1.0.4:compile
|  +- org.jboss.resteasy:resteasy-multipart-provider:jar:4.7.7.Final:compile
|  |  +- com.sun.mail:jakarta.mail:jar:1.6.5:compile
|  |  +- org.apache.james:apache-mime4j-dom:jar:0.8.3:compile
|  |  |  \- org.apache.james:apache-mime4j-core:jar:0.8.3:compile
|  |  \- org.apache.james:apache-mime4j-storage:jar:0.8.3:compile
|  +- org.jboss.resteasy:resteasy-jackson2-provider:jar:4.7.7.Final:compile
|  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.15.2:compile
|  |  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.15.2:compile
|  |  |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.15.2:compile
|  |  \- com.github.java-json-tools:json-patch:jar:1.13:compile
|  |     +- com.github.java-json-tools:msg-simple:jar:1.2:compile
|  |     |  \- com.github.java-json-tools:btf:jar:1.3:compile
|  |     \- com.github.java-json-tools:jackson-coreutils:jar:2.0:compile
|  \- org.jboss.resteasy:resteasy-jaxb-provider:jar:4.7.7.Final:compile
|     \- org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:jar:2.0.0.Final:compile
+- com.mysql:mysql-connector-j:jar:8.0.33:runtime
+- io.micrometer:micrometer-registry-prometheus:jar:1.11.2:compile
|  \- io.prometheus:simpleclient_common:jar:0.16.0:compile
|     \- io.prometheus:simpleclient:jar:0.16.0:compile
|        +- io.prometheus:simpleclient_tracer_otel:jar:0.16.0:compile
|        |  \- io.prometheus:simpleclient_tracer_common:jar:0.16.0:compile
|        \- io.prometheus:simpleclient_tracer_otel_agent:jar:0.16.0:compile
+- com.github.javafaker:javafaker:jar:1.0.2:compile
|  +- org.apache.commons:commons-lang3:jar:3.12.0:compile
|  +- org.yaml:snakeyaml:jar:android:1.23:compile
|  \- com.github.mifmif:generex:jar:1.0.2:compile
|     \- dk.brics.automaton:automaton:jar:1.11-8:compile
+- org.modelmapper:modelmapper:jar:3.0.0:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.15.2:compile
|  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.2:compile
|  \- com.fasterxml.jackson.core:jackson-core:jar:2.15.2:compile
\- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.15.2:compile
8

到目前为止唯一的解决方案是:更改 log4j2

2

Devtools 有时会导致类加载器问题,您可以尝试暂时删除它,看看问题是否仍然存在。

9

示例中的一些调试显示真正的原因如下:

ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:69)
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:44)
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:33)
    at ch.qos.logback.core.model.processor.AppenderModelHandler.handle(AppenderModelHandler.java:67)
    at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:241)
    at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:253)
    at ch.qos.logback.core.model.processor.DefaultProcessor.traversalLoop(DefaultProcessor.java:90)
    at ch.qos.logback.core.model.processor.DefaultProcessor.process(DefaultProcessor.java:106)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.processModel(GenericXMLConfigurator.java:210)
    at org.springframework.boot.logging.logback.SpringBootJoranConfigurator.processModel(SpringBootJoranConfigurator.java:122)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:174)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:126)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:69)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.configureByResourceUrl(LogbackLoggingSystem.java:272)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:242)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:187)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:356)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at com.example.demo.DemoApplication.main(DemoApplication.java:10)
Caused by: java.lang.NoClassDefFoundError: jakarta/mail/internet/AddressException
    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3373)
    at java.base/java.lang.Class.getConstructor0(Class.java:3578)
    at java.base/java.lang.Class.getConstructor(Class.java:2271)
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:61)
    ... 37 more
Caused by: java.lang.ClassNotFoundException: jakarta.mail.internet.AddressException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 42 more
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:69)
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:44)
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:33)
    at ch.qos.logback.core.model.processor.AppenderModelHandler.handle(AppenderModelHandler.java:67)
    at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:241)
    at ch.qos.logback.core.model.processor.DefaultProcessor.secondPhaseTraverse(DefaultProcessor.java:253)
    at ch.qos.logback.core.model.processor.DefaultProcessor.traversalLoop(DefaultProcessor.java:90)
    at ch.qos.logback.core.model.processor.DefaultProcessor.process(DefaultProcessor.java:106)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.processModel(GenericXMLConfigurator.java:210)
    at org.springframework.boot.logging.logback.SpringBootJoranConfigurator.processModel(SpringBootJoranConfigurator.java:122)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:174)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:126)
    at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:69)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.configureByResourceUrl(LogbackLoggingSystem.java:272)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:242)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:187)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:356)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at com.example.demo.DemoApplication.main(DemoApplication.java:10)
Caused by: java.lang.NoClassDefFoundError: jakarta/mail/internet/AddressException
    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3373)
    at java.base/java.lang.Class.getConstructor0(Class.java:3578)
    at java.base/java.lang.Class.getConstructor(Class.java:2271)
    at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:61)
    ... 37 more
Caused by: java.lang.ClassNotFoundException: jakarta.mail.internet.AddressException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 42 more

可以通过向 POM 添加邮件依赖项来解决这个问题:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-mail</artifactId>
</dependency>

事实上,没有报告实际原因并不好,我已经打开了#36645,看看我们是否可以改进这一点。

3

我刚刚注意到您javax.mail:javax.mail-api在上面的评论中列出了您的依赖项,您需要切换到雅加达版本。

6

@robozb 啊是的,这是一个有趣的小调试技巧。我添加了一个异常断点ModelHandlerException。这让我停在了AppenderModelHandler第 75 行。然后我添加了一个监视表达式,oops.printStackTrace()这让我在控制台中找到了真正的原因。