Do initialization after the project starts
Many operations are intended to be performed after the project starts, such as:
- Write the sensitive words of the database into the memory
- Synchronize redis data
- Synchronize mysql data
- …
The storage location of the startup class is as follows:
@EnableScheduling
@SpringBootApplication
public class FristApplication {
public static void main(String[] args) {
SpringApplication.run(FristApplication.class, args);
}
}
@Slf4j
@Component
class ApplicationRunnerImpl implements ApplicationRunner {
@Autowired
private TaskHanderComponent taskHanderComponent;
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("||==================================开始初始化==================================||");
log.info("||==================================执行任务==================================||");
// 把数据库的敏感词写进内存中
// 同步redis数据
// taskHanderComponent.syncSensitive();
}
}