Could not autowire org.springframework.mail.javamail.JavaMailSender

前端 未结 8 745
时光取名叫无心
时光取名叫无心 2021-02-11 22:18

I got the following problem when trying to run my application. Have debugged everything and still nothing.

The IDE is finding the bean without any issue so I\'m very con

相关标签:
8条回答
  • 2021-02-11 23:17

    As already stated you need to set at least spring.mail.host in your application properties. Spring Boot autoconfiguration only creates a JavaMailSender bean if the property is set: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderPropertiesConfiguration.java#L38

    0 讨论(0)
  • 2021-02-11 23:17

    Configuring in application.properties for spring.mail related properties are good enough to do Autowire of JavaMailSender. In our case, someone also had Bean declaration and hence this was taking precedence over application.properties. Hence, Autowired was not showing. I hope this helps one.

    0 讨论(0)
提交回复
热议问题