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
原文地址:https://www.cnblogs.com/chencn/p/12461549.html