啟動SpringBoot報JavaMail加載錯誤的原因分析和解決
啟動SpringBoot時,報如下mail加載錯誤:
*************************** APPLICATION FAILED TO START *************************** Description: A component required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found. Action: Consider defining a bean of type 'org.springframework.mail.javamail.JavaMailSender' in your configuration.
可以從如下幾個方面檢查:
1)是否已在項目Maven POM中添加依賴:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency>
2)是否在代碼中已注入:
@Resource private JavaMailSender mailSender;
3)是否在yaml中配置smtp和賬號信息:
spring: mail: host: smtp.xxx.com port: 465 protocol: smtps username: my-username password: email-code properties: mail: smtp: auth: true ssl: enable: false
如果是SSL,則端口號為465,而協(xié)議必須為smtps;否則默認的可不需要配置的25端口號和smtp協(xié)議。
到此這篇關于啟動SpringBoot報JavaMail加載錯誤的原因分析和解決的文章就介紹到這了,更多相關啟動SpringBoot報JavaMail加載錯誤內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
- 解決springboot+activemq啟動報注解錯誤的問題
- springboot項目啟動,但是訪問報404錯誤的問題
- 記一次springboot配置redis項目啟動時的一個奇怪的錯誤
- 解決Springboot啟動報錯:類文件具有錯誤的版本61.0,應為?52.0
- 啟動springboot項目時報錯:無法訪問org.springframework.web.bind.annotation.GetMapping …具有錯誤的版本 61.0,應為52.0?的解決方案
- SpringBoot項目啟動打包報錯類文件具有錯誤的版本 61.0, 應為 52.0的解決方法
- springboot項目啟動類錯誤(找不到或無法加載主類 com.**Application)
- spring boot啟動出現(xiàn)Unable to start ServletWebServerApplicationContext due to missing ServletWebServer錯誤解決
相關文章
vue+springboot+shiro+jwt實現(xiàn)登錄功能
這篇文章主要介紹了vue+springboot+shiro+jwt實現(xiàn)登錄功能,本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04Java編程之多線程死鎖與線程間通信簡單實現(xiàn)代碼
這篇文章主要介紹了Java編程之多線程死鎖與線程間通信簡單實現(xiàn)代碼,具有一定參考價值,需要的朋友可以了解下。2017-10-10Mybatis-Plus使用saveOrUpdate及問題解決方法
本文主要介紹了Mybatis-Plus使用saveOrUpdate及問題解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-01-01深入理解Java基礎之try-with-resource語法糖
這篇文章主要介紹了深入理解Java基礎之try-with-resource語法糖,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-02-02