spring boot 程序启动后执行自定义任务

@Component
@Order(value = 1)
public class startApplication implements ApplicationRunner {
    @Autowired
    private DesMobileEmailService desMobileEmailService;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        Integer result = 0;
        do {
            try {
                result = desMobileEmailService.DesSlPasswordIDMapMobileEmail();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } while ( result == 1 );
    }
}

猜你喜欢

转载自blog.csdn.net/xx1qaz/article/details/86237389