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. OS开发(Objective-C)常用库索引

    code4app.com 这网站不错,收集各种 iOS App 开发可以用到的代码示例 cocoacontrols.com/ 英文版本的lib收集 objclibs.com/ 精品lib的收集网站 h ...

  2. 【leetcode❤python】 438. Find All Anagrams in a String

    class Solution(object):    def findAnagrams(self, s, p):        """        :type s: s ...

  3. iOS日常工作之常用宏定义大全

    前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定义了怎么办?本人在工作中也是如此.所以在这里给大家分享一些常用的宏定义,喜欢的小伙伴可 ...

  4. Change An Item Property Using Set_Item_Property In Oracle Forms

    Set_Item_Property is used to change an object's settings at run time. Note that in some cases you ca ...

  5. ubuntu安装miniconda

    系统:ubuntu15.04   64位 wget -c http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh chm ...

  6. apue和error

    在做进程环境测试的时候,测试demo中出现了apue.h,而标准库中没有这个头文件和其中的函数定义,经查找需要在/usr/include中添加apue.h和error.c.原型可以去这个网站查找.   ...

  7. 数据引用Data References

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  8. Typescript的面向对象

    封装: var Greeter = (function () { function Greeter(message) { this.greeting = message; } Greeter.prot ...

  9. [poj2286]The Rotation Game (IDA*)

    //第一次在新博客里发文章好紧张怎么办 //MD巨神早已在一个小时前做完了 The Rotation Game Time Limit: 15000MS Memory Limit: 150000K To ...

  10. Android调用系统 Set As Intent

    调用方法如下: Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); intent.addCategory(Intent.CATEGORY_DE ...