1、spring的default-lazy-init参数

spring在启动的时候,会默认加载会默认加载整个对象实例图,从初始化ACTION配置、到 service配置到dao配置、乃至到数据库连接、事务等等。这样可以减少web服务器在运行时的负担,但是对于开发者来说无疑是效率极低的一个设置了。 
spring提供了default-lazy-init属性,其配置形式如下,applicationContext.xml中: 
< beans  default-lazy-init ="true" >   
</beans>

我用以前一个office项目测试了下,因为office的spring文件很多,我就配置了下,启动时间减少60%左右。

2、Spring 中lazy-init 和abstract 属性 
1.lazy-init 
<beans> 
      <bean id="service1" type="bean路径" lazy-init="true"/> 
      <bean id="service2" type="bean路径" lazy-init="false"> 
             <property name="service1" ref="service1"/> 
      </bean> 
</beans> 
以上两个bean,一个lazy-init属性为true,一个为false,由什么区别呢 
当 IoC容器启动时,service2会实例化,而service1则不会;但是但容器实例化service2时,service1也被实例化了,为什么呢,因为service2需要它。也就是说lazy-init="true"的bean,IoC容器启动时不会实例化该bean,只有当容器需要用到时才实例化它。lazy-init有利于容器效率,对于不需要的bean可以先不管。 
2.abstract 
<bean id="baseTxService"  class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"  abstract="true"> 
</bean> 
bean abstract="true"时,该bean不会被实例化,上面的bean是个模板

能源项目xml文件标签释义--default-lazy-init的更多相关文章

  1. 能源项目xml文件标签释义--<context:component-scan>

    <context:component-scan base-package="com.xindatai.ibs" use-default-filters="false ...

  2. 能源项目xml文件标签释义--DefaultAdvisorAutoProxyCreator

    [Spring]AOP拦截-三种方式实现自动代理 这里的自动代理,我讲的是自动代理bean对象,其实就是在xml中让我们不用配置代理工厂,也就是不用配置class为org.springframewor ...

  3. 能源项目xml文件标签释义--CommonsMultipartResolver

    <!-- 文件上传表单的视图解析器 --><bean id="multipartResolver" class="org.springframework ...

  4. 能源项目xml文件标签释义--DataSource

    <bean id="dataSource1" class="org.apache.tomcat.jdbc.pool.DataSource" destroy ...

  5. 能源项目xml文件标签释义--<mvc:annotation-driven>

    <mvc:annotation-driven />的可选配置 <mvc:annotation-driven message-codes-resolver ="bean re ...

  6. 能源项目xml文件 -- springMVC-servlet.xml -- default-lazy-init

    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w ...

  7. 能源项目xml文件 -- app-dubbo.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  8. 能源项目xml文件 -- app-datasource.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  9. 能源项目xml文件 -- app-init.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

随机推荐

  1. Json 入门例子(form表单)【0】

    <script> $(function () { var aa = $("#fm").serialize().replace(/\+/g, ""); ...

  2. strip_tags,htmlspecialchars,htmlentities,stripslashes,addslashes学习小结

    一.strip_tags 从字符串中去除 HTML 和 PHP 标记 string strip_tags ( string $str [, string $allowable_tags ] ) str ...

  3. 我的android学习经历27

    前几天忙着学校的互联网+项目比赛,没有时间学习android和发一些东西,主要是这两天太累了,我是项目组长,好多东西去弄,今天已经交稿去进行初赛. 马上收拾收拾心情,继续我的andorid菜鸟之路 加 ...

  4. Android 进度条

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  5. oracle, create table, insufficient privileges

    SQL> exec pro_gz_day_report;          ORA-01031: insufficient privileges          ORA-06512: at & ...

  6. .NET/C# 使用Stopwatch测量运行时间

    Stopwatch类:http://msdn.microsoft.com/zh-cn/library/system.diagnostics.stopwatch(v=vs.100).aspx 常用属性和 ...

  7. bzoj 1588: [HNOI2002]营业额统计 treap

    1588: [HNOI2002]营业额统计 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 13902  Solved: 5225[Submit][Sta ...

  8. CSS笔记(八)表格

    参考:http://www.w3school.com.cn/css/css_table.asp 实例: <html> <head> <style type="t ...

  9. Andoid java文件中的Log检查工具

    AndroidLogChecker 由于发布软件版本的时候我们需要把Log注释掉,此工具可以检查java类中的Log所在行以及是否已经注释. Github: https://github.com/cu ...

  10. springmvc前后端传值

    @pathvible 后端传值(rest风格) exp: @requestMapping("/view/{userId}") public String getiew(@Parth ...