springboot写发送邮件报错Field javaMailSender in com.gzh.service.impl.IMailServiceImpl
大家好,我是小铁,一个酷比的程序员
大家先来看一下报错
Description:
Field javaMailSender in com.gzh.service.impl.IMailServiceImpl required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found.The injection point has the following annotations:@org.springframework.beans.factory.annotation.Autowired(required=true)Action:
Consider defining a bean of type 'org.springframework.mail.javamail.JavaMailSender' in your configuration.
这个的意思就是说,在我们启动springboot项目的时候,springboot自动注入JavaMailSender这个接口的时候,发生了注入失败的情况
请耐心看完,或许对你有一些帮助
一、我们先看pom.xml文件,首先我们应该添加这个发送邮件的依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId>
</dependency>
二、这个是发送邮件的代码,这个没什么说的
@Overridepublic void sendSimpleMail(String to, String subject, String content) {//创建SimpleMailMessage对象SimpleMailMessage message = new SimpleMailMessage();//邮件发送人message.setFrom(from);//邮件接收人message.setTo(to);//邮件主题message.setSubject(subject);//邮件内容message.setText(content);//发送邮件javaMailSender.send(message);}
三、配置文件(已经做了处理了)
spring:mail:host: smtp.qq.com #我用的是qq,用其他的也是一样username: xxxxxxx@qq.com #这个是qq邮箱password: xxxxxxxxx #注意这个不是密码,是客户端授权码default-encoding: utf-8 #这个是字符集,咱们用utf-8就可以了
针对以上的错误,咱们检查这些基本就可以解决了。
如果,代码还是报错,可以私信小铁。把报错截图发一下就可以
springboot写发送邮件报错Field javaMailSender in com.gzh.service.impl.IMailServiceImpl相关推荐
- SpringBoot写配置文件报错“The elements [xxx,xxx] were left unbound.“
异常 在SpringBoot的配置文件application.yaml中写配置报错: 2021-06-22 21:01:01.962 WARN 28928 --- [ main] ConfigServ ...
- springboot项目启动报错Field Mapper in ServiceImpl required a bean of type ‘Mapper‘ that could not be found
1.报错: Error starting ApplicationContext. To display the conditions report re-run your application wi ...
- Field cscpUserDetailRepository in com.ctsi.service.impl.OfficialDocumentHandleServiceImpl required a
说明:在项目启动的时候报下面的错 Field cscpUserDetailRepository in com.ctsi.service.impl.OfficialDocumentHandleServi ...
- SpringBoot项目启动报错:Field userMapper in com.demo.controller.MemberController required a bean of type ‘c
问题描述: SpringBoot项目启动报错,报错内容:'com.xxx.mapper.XxxxMapper' that could not be found ******************** ...
- SpringBoot报错Field userService in XXTestController required a bean of type 'XX' that could not be...
运行SpringBoot项目报错Field userService in XXXTestController required a bean of type 'XXX' that could not ...
- springboot使用redisTemplate 报错:APP FAILED TO START Field template in required a single bean redis工具类
springboot使用redisTemplate 报错: template in com.j.ssm.tool.RedisUtil required a single bean, but 2 wer ...
- springBoot启动类报错
关于SpringBoot启动类报错的问题解决: APPLICATION FAILED TO START Description: Field elasticsearchRestTemplate in ...
- pandas写excel报错ModuleNotFoundError: No module named ‘xlwt‘
pandas写excel报错ModuleNotFoundError: No module named 'xlwt' https://blog.csdn.net/weixin_36372879/arti ...
- SpringBoot 整合Redis报错:NoClassDefFoundError: redis/clients/util/SafeEncoder
QUESTION:SpringBoot 整合Redis报错:NoClassDefFoundError: redis/clients/util/SafeEncoder? ANSWER: 这种情况是版本不 ...
- python打开文件报错无效序列_解决Python 写文件报错TypeError的问题
处理上传的文件: f1 = request.FILES['pic'] fname = '%s/%s' % (settings.MEDIA_ROOT, f1.name) with open(fname, ...
最新文章
- 自定义监听器 java
- BZOJ4573 : [Zjoi2016]大森林
- Python 技术篇-利用Office VBA实现word文档转化为pdf文档实例演示
- php无法下单功能,PHP如何解决并发下单问题?(不一定是下单,举个例)
- 简述与oracle相关的程序组,oracle数据库复习程序.doc
- linux mysql 每天备份_Linux下Mysql每天自动备份
- Java I/O(输入输出流)
- dell 2u服务器型号,IBM、HP、Dell比拼主流2U双路服务器
- Spring系列七:JDK 动态代理和 CGLIB 代理
- 计算机基础知识2003,计算机基础知识PPT2003练习题及答案(DOC)
- 人全外显子组测序WES学习笔记 第一天
- 开发用的到java数组吗_java数组
- Java打印一个正三角形
- rrweb学习案例(网页录制,回放)-demo
- 转载一篇过来人谈的大学期间关于课外学习的意见lt;出自左飞老师笔记gt;
- jib构建镜像(使用阿里云容器镜像服务拉取镜像)
- Emlog程序CYP音乐主题模板源码
- 【C#语言】具名类型和匿名类型
- 解决小米远程管理下电脑出现ftp文件错误提示
- [luogu]P1600 天天爱跑步[LCA]