为了防止忘记某件事,使用程序调用windows的任务提醒
1. springboot定时器
使用注解@Scheduled和@EnableScheduling
@Scheduled:设置时间
@EnableScheduling:开启定时器
2. 调用windows任务提醒
public void displayTray(String msg) throws AWTException {
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
TrayIcon trayIcon = new TrayIcon(image, "Tray Demo");
trayIcon.setImageAutoSize(true);
trayIcon.setToolTip("System tray icon demo");
tray.add(trayIcon);
trayIcon.displayMessage("每日新股更新", msg+"需更新", TrayIcon.MessageType.INFO);
}
启动类的main也得修改
public static void main(String[] args) {
SpringApplicationBuilder builder = new SpringApplicationBuilder(StockApplication.class);
builder.headless(false);
ConfigurableApplicationContext context = builder.run(args);
}