java - spring-boot 2.3.0.M4 JDK 11 集成NoSuchBeanDefinitionException ...ConfigurationClassPostProcessor, ...ProxyTransactionManagementConfiguration

标签 java spring-boot spring-security spring-data-jpa

我在我的项目中声明了 spring-boot Spring-boot 2.3.0.M4 和 JDK 11,但是我得到了一个 NoSuchBeanDefinitionException for ...ConfigurationClassPostProcessor,并且 Error creating 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!

最佳答案

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

关于java - spring-boot 2.3.0.M4 JDK 11 集成NoSuchBeanDefinitionException ...ConfigurationClassPostProcessor, ...ProxyTransactionManagementConfiguration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61238057/

相关文章:

java - Java 中单独的 { code } 是做什么用的?

java - 在 MySQL 中插入触发器之前,当从 Java 代码触发插入时会出现问题

java - Spring Boot启动缓存未触发

spring-boot - keycloak openid single log out with spring boot

java - Swagger POST 返回 403 Forbidden Spring boot Spring security

java - Spring Security 元注释

java - 从不同包中的类获取 Activity 类中的变量的最佳方法?

java - 从另一个 @Transactional 注解方法调用 @Transactional 注解方法

spring - 如何在Spring Boot中对私有(private)/ protected RequestMapping进行AOP

java - 最长的子数组,不超过两个相差不超过 1 的不同值