zoukankan      html  css  js  c++  java
  • spring的懒加载

    在spring的IOC容器中,可以通过设置<beans default-lazy-init="XXX"></beans>来设置是否为懒加载模式,懒加载的意思就是说是否在spring容器加载的时候将bean加载到容器中。在没有设置的情况下,默认是false的,就是说不使用懒加载模式。

    当设置为false(或者没有设置的时候)tomcat启动的时候出现的是:

     Initializing Spring root WebApplicationContext
    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    测试spring的lazy属性
    2015-10-13 19:06:04 org.apache.coyote.http11.Http11Protocol start
    信息: Starting Coyote HTTP/1.1 on http-8080
    2015-10-13 19:06:04 org.apache.jk.common.ChannelSocket init
    信息: JK: ajp13 listening on /0.0.0.0:8009
    2015-10-13 19:06:04 org.apache.jk.server.JkMain start
    信息: Jk running ID=0 time=0/17  config=null
    2015-10-13 19:06:04 org.apache.catalina.startup.Catalina start
    信息: Server startup in 3546 ms
    

    当设置true的时候,启动tomcat:

    Initializing Spring root WebApplicationContext
    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    2015-10-13 19:15:44 org.apache.coyote.http11.Http11Protocol start
    信息: Starting Coyote HTTP/1.1 on http-8080
    2015-10-13 19:15:44 org.apache.jk.common.ChannelSocket init
    信息: JK: ajp13 listening on /0.0.0.0:8009
    2015-10-13 19:15:44 org.apache.jk.server.JkMain start
    信息: Jk running ID=0 time=0/51  config=null
    2015-10-13 19:15:44 org.apache.catalina.startup.Catalina start
    信息: Server startup in 3912 ms
    

    这个是测试bean

    package com.yonyou.sys.utils;
    
    //测试bean 将spring容器中设置bean的配置文件 public class TestBeanLazy { public TestBeanLazy(){ System.out.println("测试spring的lazy属性"); } }

      

  • 相关阅读:
    USACO 3.3.1 Riding the Fences 骑马修栅栏(欧拉回路)
    USACO 3.2.6 Sweet Butter 香甜的黄油(最短路)
    USACO 1.3.4 Prime Cryptarithm 牛式(模拟枚举)
    USACO 1.3.3 Calf Flac(Manacher算法)
    USACO 1.2.2 Transformations 方块转换
    小希的迷宫(并查集判环)
    Is It A Tree?(并查集)
    Manacher算法——求最长回文子串
    Live Love(思维)
    Longge's problem(欧拉函数应用)
  • 原文地址:https://www.cnblogs.com/zr520/p/4875580.html
Copyright © 2011-2022 走看看