基于spring mvc注解项目 启动时初始化数据

来源:互联网 发布:管家婆软件怎么安装 编辑:程序博客网 时间:2024/06/13 14:18

基于spring mvc注解项目 启动时初始化数据

注解部分就不写了。。。。实现ApplicationListener的onApplicationEvent方法能在项目启动时执行。@SuppressWarnings("rawtypes")@Repositorypublic class GetData implements ApplicationListener{        @Autowired        @Qualifier("pageDao")         private PageDao pageDao;        private static boolean isStart = false;   public void onApplicationEvent(ApplicationEvent arg0) {                // TODO Auto-generated method stub           if (!isStart) {//这个可以解决项目启动加载两次的问题                   isStart= true;                   pageDao.delAll();                   getCompanyNodeList(Constants.companyUrl);           }        }   public  List<PageData> getCompanyNodeList(String url) {          //需要的操作 如:pageDao.save()}

原文地址:http://home.bdqn.cn/thread-29912-1-1.html

0 0
原创粉丝点击