diff --git a/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java b/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java index c467780..40de3e4 100644 --- a/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java +++ b/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java @@ -2,6 +2,7 @@ package com.topsail.scheduletask.task; import com.alibaba.fastjson.JSON; import com.topsail.scheduletask.service.AmqpService; +import com.topsail.scheduletask.util.MaiSenderlUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -18,7 +19,8 @@ import java.util.Map; @Configuration //1.主要用于标记配置类,兼备Component的效果。 @EnableScheduling // 2.开启定时任务 public class CheckRabbitMqScheduleTask { - + @Autowired + private MaiSenderlUtil maiSenderlUtil; @Autowired private Environment env; @Autowired @@ -53,7 +55,18 @@ public class CheckRabbitMqScheduleTask { amqpService.SendMessage("mailNotice", json); } } - +// @Scheduled(cron = "1/60 * * * * ?") +// //或直接指定时间间隔,例如:5秒 +//// @Scheduled(fixedRate=5000) +// private void checkMail() { +// try { +// maiSenderlUtil.sendMail("1129801211@qq.com", "测试邮件--主题", "测试邮件--内容", true, null, "测试邮件"); +// }catch (Exception e){ +// e.printStackTrace(); +// System.out.println("发送邮件失败"); +// System.out.println(e.getMessage()); +// } +// } public static void main(String[] args) { Map queueMessageCountMap = new HashMap<>(); queueMessageCountMap.put("queue1", 1000L); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 141bb1a..1178f0a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -49,8 +49,8 @@ spring.mail.default-encoding=UTF-8 spring.mail.properties.mail.smtp.ssl.enable=true spring.mail.properties.mail.smtp.socketFactory.port=994 spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory -mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl - +spring.mail.properties.mail.smtp.socketFactory.fallback=false +spring.mail.properties.mail.smtp.ssl.protocols=TLSv1.2 ### 监控配置 ### monitor.service.timeout=30 monitor.mq.max-accumulation=1000