【发布时间】:2020-02-19 02:49:30
【问题描述】:
想基于spring-boot-starter-mail实现简单的邮件发件人解决方案
添加依赖项并设置属性后,我尝试运行应用程序并发生错误。
我认为值得注意的是,我不是,也不是要实现 Spring Cloud。只是邮件服务。
不明白为什么 spring boot 需要来自这些包的一些服务。
尝试了各种版本的依赖,定义了一些 @Beans 但不认为这是问题
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
日志:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-23 00:07:05.752 ERROR 19576 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 1 of method mailNotifier in de.codecentric.boot.admin.server.config.AdminServerNotifierAutoConfiguration$MailNotifierConfiguration required a bean of type 'de.codecentric.boot.admin.server.domain.entities.InstanceRepository' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'instanceRepository' in 'AdminServerAutoConfiguration' not loaded because @ConditionalOnBean (types: de.codecentric.boot.admin.server.config.AdminServerMarkerConfiguration$Marker; SearchStrategy: all) did not find any beans of type de.codecentric.boot.admin.server.config.AdminServerMarkerConfiguration$Marker
Action:
Consider revisiting the entries above or defining a bean of type 'de.codecentric.boot.admin.server.domain.entities.InstanceRepository' in your configuration.
只想通过 smtp.gmail.com 发送电子邮件
希望spring-boot-starter-mail 就足够了。
谢谢!
【问题讨论】:
-
您似乎正在使用其他依赖项,例如导致错误的 Spring Boot Admin。如果您只想发送邮件,我认为将
spring-boot-starter-parent、spring-boot-starter和spring-boot-starter-mail添加到您的POM 文件中就足够了。
标签: java spring spring-boot email smtp