码迷,mamicode.com
首页 > 编程语言 > 详细

SpringMvc 系统启动时加载数据到内存中

时间:2017-11-11 11:33:53      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:ice   tail   package   服务   系统   load   oid   struts   --   

SpringMvc 系统启动时加载数据到内存中

学习了:http://blog.csdn.net/newstruts/article/details/18668269

https://www.cnblogs.com/zhengteng/p/5381910.html

http://xfxlch.iteye.com/blog/2048049

http://duanxuchu.iteye.com/blog/2181647

结论:

方案一:

<!--beans.xml中配置 扫描服务包 -->
<context:component-scan base-package="com.stono.service" />

package com.stono.service
@Service
@Lazy(false) // 注意这句
public class LoadDataService implements ServletContextAware {

    @Autowired
    TblMapper tblMapper;
    
    @Override
    public void setServletContext(ServletContext context) {

        }
}

 

方案二:

<!--在beans.xml 中进行配置-->
<bean id="loadDataService" class="com.stono.service.LoadDataService"   lazy-init="false">
</bean>

package com.stono.serivce

@Service // @Component // 写成@Component也可以
public class LoadDataService implements ServletContextAware {
    @Autowired
    TblMapper tblMapper;
        @Override
    public void setServletContext(ServletContext context) {
        }
}

 

SpringMvc 系统启动时加载数据到内存中

标签:ice   tail   package   服务   系统   load   oid   struts   --   

原文地址:http://www.cnblogs.com/stono/p/7818123.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!