大家好,我是小铁,一个酷比的程序员

大家先来看一下报错

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相关推荐

  1. SpringBoot写配置文件报错“The elements [xxx,xxx] were left unbound.“

    异常 在SpringBoot的配置文件application.yaml中写配置报错: 2021-06-22 21:01:01.962 WARN 28928 --- [ main] ConfigServ ...

  2. 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 ...

  3. Field cscpUserDetailRepository in com.ctsi.service.impl.OfficialDocumentHandleServiceImpl required a

    说明:在项目启动的时候报下面的错 Field cscpUserDetailRepository in com.ctsi.service.impl.OfficialDocumentHandleServi ...

  4. SpringBoot项目启动报错:Field userMapper in com.demo.controller.MemberController required a bean of type ‘c

    问题描述: SpringBoot项目启动报错,报错内容:'com.xxx.mapper.XxxxMapper' that could not be found ******************** ...

  5. 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 ...

  6. 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 ...

  7. springBoot启动类报错

    关于SpringBoot启动类报错的问题解决: APPLICATION FAILED TO START Description: Field elasticsearchRestTemplate in ...

  8. pandas写excel报错ModuleNotFoundError: No module named ‘xlwt‘

    pandas写excel报错ModuleNotFoundError: No module named 'xlwt' https://blog.csdn.net/weixin_36372879/arti ...

  9. SpringBoot 整合Redis报错:NoClassDefFoundError: redis/clients/util/SafeEncoder

    QUESTION:SpringBoot 整合Redis报错:NoClassDefFoundError: redis/clients/util/SafeEncoder? ANSWER: 这种情况是版本不 ...

  10. python打开文件报错无效序列_解决Python 写文件报错TypeError的问题

    处理上传的文件: f1 = request.FILES['pic'] fname = '%s/%s' % (settings.MEDIA_ROOT, f1.name) with open(fname, ...

最新文章

  1. 自定义监听器 java
  2. BZOJ4573 : [Zjoi2016]大森林
  3. Python 技术篇-利用Office VBA实现word文档转化为pdf文档实例演示
  4. php无法下单功能,PHP如何解决并发下单问题?(不一定是下单,举个例)
  5. 简述与oracle相关的程序组,oracle数据库复习程序.doc
  6. linux mysql 每天备份_Linux下Mysql每天自动备份
  7. Java I/O(输入输出流)
  8. dell 2u服务器型号,IBM、HP、Dell比拼主流2U双路服务器
  9. Spring系列七:JDK 动态代理和 CGLIB 代理
  10. 计算机基础知识2003,计算机基础知识PPT2003练习题及答案(DOC)
  11. 人全外显子组测序WES学习笔记 第一天
  12. 开发用的到java数组吗_java数组
  13. Java打印一个正三角形
  14. rrweb学习案例(网页录制,回放)-demo
  15. 转载一篇过来人谈的大学期间关于课外学习的意见lt;出自左飞老师笔记gt;
  16. jib构建镜像(使用阿里云容器镜像服务拉取镜像)
  17. Emlog程序CYP音乐主题模板源码
  18. 【C#语言】具名类型和匿名类型
  19. 解决小米远程管理下电脑出现ftp文件错误提示
  20. [luogu]P1600 天天爱跑步[LCA]

热门文章

  1. 百度SEO与SEM的区别
  2. php 后台文章分页功能,php简单实例:文章分页功能
  3. Python+Opencv检测模糊图片
  4. 【云原生】Kubernetes编排工具精讲
  5. 软件测试笔记2-目的
  6. 微积分(一)——二重积分与三重积分笔记
  7. vue+element实现手机号验证码注册
  8. 第八章 Python之常用模块
  9. 图片去底色怎么去?图片怎么去底色变透明?
  10. WPS 设置多级标题