springboot 启动加载

springboot项目中需程序启动,就执行方法.

实现方法

1.实现ApplicationRunner接口

@Service
public class GpsRealDataServiceImpl implements ApplicationRunner

注意:实现类一定要受spring管理  将GpsRealDataServiceImpl 上加入注解,变成spring的bean

2.实现run()方法

 @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        启动程序,执行的代码
    }

猜你喜欢

转载自blog.csdn.net/guangyingposuo/article/details/88942643