Spring Scope与Lazy
来源:互联网 发布:nginx 在线人数统计 编辑:程序博客网 时间:2024/06/03 07:14
package com.sanmao.spring.test;import com.sanmao.spring.ioc.HelloWorld;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;/** * Created by root on 16-9-26. */public class ScopeTest { /** * 在默认情况下,Spring容器产生的对象是单例的 * */ @Test public void testScope_Default(){ //启动sping容器 ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml"); //从spring容器中把对象提取出来 HelloWorld helloWorld=(HelloWorld)context.getBean("helloWorld"); System.out.println(helloWorld); HelloWorld helloWorld1=(HelloWorld)context.getBean("helloWorld"); System.out.println(helloWorld1); } /** * 如果scope为prototype,则为多实例 * */ @Test public void testScope_Prototype(){ //启动sping容器 ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml"); //从spring容器中把对象提取出来 HelloWorld helloWorld2=(HelloWorld)context.getBean("helloWorld"); HelloWorld helloWorld3=(HelloWorld)context.getBean("helloWorld"); System.out.println(helloWorld2); System.out.println(helloWorld3); }}
public class ScopeLazy { /** * 如果scope为prototype,则lazy-init 将失去作用 * */ @Test public void testScope_Prototype_Lazy_Defalut(){ ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml"); HelloWorld helloWorld2=(HelloWorld)context.getBean("helloWorld"); HelloWorld helloWorld3=(HelloWorld)context.getBean("helloWorld"); System.out.println(helloWorld2); System.out.println(helloWorld3); }}
0 0
- Spring Scope与Lazy
- spring的scope理解与自定义scope
- Struts与Spring整合Scope
- Spring的default-lazy-init 与 lazy-init
- spring(4)_ bean属性 scope:作用域和lazy-init
- Spring lazy
- spring scope prototype与singleton区别
- 【Spring】scope:"singleton"与"prototype"学习记录
- spring scope prototype与singleton区别
- spring scope prototype与singleton区别
- spring scope prototype与singleton区别
- spring scope
- spring scope
- Spring-scope
- Spring Scope
- Spring scope
- Spring-scope
- Spring Scope
- static、final、接口、抽象类互相结合时的细节问题总结
- UVA 12716
- CSS基础入门
- Qt中为工程添加资源文件、给按钮添加图片
- 源码-JavaScript&jQuery交互式前端开发-第2章-JavaScript基础指令-使用变量来存储布尔值
- Spring Scope与Lazy
- stm32 使用malloc申请内存和free释放内存造成的内存碎片测试
- 重写ViewPager,禁止其左右滑动
- 找规律,数学(巨大的斐波那契数列,uva 11582)
- Android动画
- JSON与JSONP的区别于实现
- 数组三种实现方式
- unity shader编写(一),漫反射shader实现
- angular1 之 动画篇