zoukankan      html  css  js  c++  java
  • springboot ---邮件和定时任务 和异步

    1.搭建环境: 导入包 :spring-boot-starter-mail  和spring-boot-starter-quartz包      Async 用到了代理?

    mail的主要配置:
    spring.mail.host=smtp.qq.com
    spring.mail.username=1525524631@qq.com
    spring.mail.password=qjpgiccfbjkphdbc
    spring.mail.properties.mail.smtp.auth=true
    spring.mail.properties.mail.smtp.starttls.enable=true
    spring.mail.properties.mail.smtp.starttls.enable.required=true
    spring.mail.default-encoding=utf-8
    关键类:
    JavaMailSenderImpl    mainSender;

    mail简单邮件模式: new SimpleMailMessage()
    mail复杂邮件模式:
    MimeMessage mimeMessage = mailSender.createMimeMessage();  
    MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
    mimeMessageHelper.addAttachment(filename,file);
    mainSender.send(实例对象);

    定时任务配置:    

    关键注解:@EnableScheduling    
    @Scheduled(cron="10 * * * * ?")
    关键定时任务表达式:cron=" *  *  *   *  *  *”
    分别代表秒   分   时    月天  月   星期
    10秒代表 启动后没秒的第10秒开始执行任务。
    ?代表 无论什么时候 都执行
    * 表示匹配所有值
    /  代表每隔多长时间

    异步:

    @EnableAsync
    @Async
  • 相关阅读:
    C#double类型转换string类型
    数据分析测试
    第三周进度
    质量属性战术——可用性战术
    开学第二周进度报告
    开学第一周进度报告
    质量属性的六个常见属性场景
    架构漫谈有感03
    架构漫谈有感02
    读架构漫谈有感--软件架构师如何工作
  • 原文地址:https://www.cnblogs.com/chencn/p/12461549.html
Copyright © 2011-2022 走看看