[英]Sending Email via Spring boot “spring-boot-starter-mail”
[英]"Application failed to start" after spring-boot-starter-mail usage
想要基於spring-boot-starter-mail
實現簡單的郵件發件人解決方案添加依賴項並設置屬性后,我嘗試運行應用程序並發生錯誤。 我認為值得注意的是,我不是,也不是要實施 Spring Cloud。 只是郵件服務。 不明白為什么 spring 啟動需要一些來自這些 package 的服務。
嘗試了各種版本的依賴項,定義了一些 @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.Z4D236D9A2D102C5FE6AD1C50 spring-boot-starter-mail
DA4B 發送 email
謝謝!
正如 LHCHIN 評論的那樣,這是<dependencyManagement/>
中的spring-boot-admin-starter-server
和spring-boot-admin-dependencies
的問題
我總是建議避免使用它們的版本復制粘貼依賴項。 大多數情況下您不需要指定版本,讓 Spring 引導根據 mvn 找出適合您的版本。
對於 spring 引導啟動郵件,我只需要以下依賴項
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.5.6</version>
</dependency>
我使用的來源是: https://www.baeldung.com/spring-email ,無論有沒有版本,它都對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.