Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PostConstruct注解用于方法上,该方法在初始化的依赖注入操作之后被执行。
- //这个方法必须在class被放到service之后被执行,这个注解所在的类必须支持依赖注入
- @PostConstruct
- public void init(){
- //todo 业务逻辑
- }
- //Springboot 项目启动后执行某些自定义代码
- @Component
- public class MyApplicationRunner implements ApplicationRunner {
- @Override
- public void run(ApplicationArguments applicationArguments) throws Exception {
- System.out.println("-------------->" + "项目启动,now=" + new Date());
- //todo 业务逻辑
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement