Spring-boot 2.3.0.M4 JDK 11 集成 NoSuchBeanDefinitionException ...ConfigurationClassPostProcessor, ...

Posted

技术标签:

【中文标题】Spring-boot 2.3.0.M4 JDK 11 集成 NoSuchBeanDefinitionException ...ConfigurationClassPostProcessor, ...ProxyTransactionManagementConfiguration【英文标题】:Spring-boot 2.3.0.M4 JDK 11 Integrated NoSuchBeanDefinitionException ...ConfigurationClassPostProcessor, ...ProxyTransactionManagementConfiguration 【发布时间】:2020-07-28 23:21:39 【问题描述】:

我在我的项目中声明了 spring-boot Spring-boot 2.3.0.M4 和 JDK 11,但是我得到了一个 NoSuchBeanDefinitionException for ...ConfigurationClassPostProcessor,并且 Error created bean with name...ProxyTransactionManagementConfiguration 这是堆栈跟踪:

 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]

...

 at com.main(EcApplication.java:24) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailSender' defined in class path resource [org/springframework/boot/autoconfigure/mail/MailSenderPropertiesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.mail.javamail.JavaMailSenderImpl]: Factory method 'mailSender' threw exception; nested exception is java.lang.NoClassDefFoundError: com/sun/activation/registries/LogSupport
 at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]

...

org.springframework.mail.javamail.ConfigurableMimeFileTypeMap.createFileTypeMap(ConfigurableMimeFileTypeMap.java:151) ~[spring-context-support-5.2.5.RELEASE.jar:5.2.5.RELEASE]
 at
...
org.springframework.boot.autoconfigure.mail.MailSenderPropertiesConfiguration.mailSender(MailSenderPropertiesConfiguration.java:44) ~[spring-boot-autoconfigure-2.3.0.M4.jar:2.3.0.M4]
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
 at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
 at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
 at 
...
 at com.main(EcApplication.java:24) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
 at ...
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
 ... 38 common frames omitted   ```




I searched and found it is not **@Autowire**  is not creating bean but nothing helped.



 @RestController
 public class CheckoutResource  
     @Autowired
     private JavaMailSender mailSender;
 

Can anyone help me? Thanks!

【问题讨论】:

【参考方案1】:

这纯粹是自动连线问题,即在运行应用程序时找不到邮件发件人类,请确保您在 ide 中使用正确版本的 java。

【讨论】:

正如我在问题中提到的那样,我正在将我的应用程序更新为 java 11 和 spring boot 2.3.0.M4。

以上是关于Spring-boot 2.3.0.M4 JDK 11 集成 NoSuchBeanDefinitionException ...ConfigurationClassPostProcessor, ...的主要内容,如果未能解决你的问题,请参考以下文章

jdk keytools for spring-boot

第一章 第一个spring boot程序

spring-boot重新学习

spring-boot与阿里大于短信发送平台

带有spring-boot的自定义sql中的Liquibase参数

如何将 Gatling 与现有的 Spring-Boot + Gradle 应用程序集成