spring 疑问汇总
来源:互联网 发布:植村秀淘宝旗舰店 编辑:程序博客网 时间:2024/05/22 14:20
1. 关于constructor-arg:
【xml】
<bean name="conService" class="io.lin.common.spring.conarg.ConstructService">
<constructor-arg name="name" value="aaaa"></constructor-arg>
<constructor-arg name="num" value="12"></constructor-arg>
<constructor-arg name="bool" value="true"></constructor-arg>
</bean>
<bean name="prototypeConService" class="io.lin.common.spring.conarg.ConstructService" scope="prototype">
<constructor-arg name="name" value="aaaa"></constructor-arg>
<constructor-arg name="bool" value="true"></constructor-arg>
<constructor-arg name="num" value="12"></constructor-arg>
</bean>
<bean name="lazyConService" class="io.lin.common.spring.conarg.ConstructService" lazy-init="true">
<constructor-arg name="name" value="aaaa"></constructor-arg>
<constructor-arg name="num" value="12"></constructor-arg>
<constructor-arg name="bool" value="true"></constructor-arg>
</bean>
【java】
//test default
ConstructService conService = (ConstructService) context.getBean("conService",new String("xxxx"),new Boolean(true),new Integer(1));
String result = conService.toString();
Assert.assertEquals("aaaa true 12", result);
//test prototype
ConstructService prototypeConService1= (ConstructService) context.getBean("prototypeConService");
String result1 = prototypeConService1.toString();
Assert.assertEquals("aaaa true 12", result1);
ConstructService prototypeConService2 = (ConstructService) context.getBean("prototypeConService",new String("xxxxxxxxx"),new Boolean(true),new Integer(1));
String result2 = prototypeConService2.toString();
Assert.assertEquals("xxxxxxxxx true 1", result2);
//test singleton & lazy-init
ConstructService lazyConService = (ConstructService) context.getBean("lazyConService",new String("rrrr"),new Boolean(true),new Integer(1));
Assert.assertEquals("rrrr true 1", lazyConService.toString());
ConstructService lazyConService2 = (ConstructService) context.getBean("lazyConService");
Assert.assertEquals("rrrr true 1", lazyConService2.toString());
2.context:component-scan
2.1)bean已经写在xml里面,但base-package路径又重复包含该bean。xml重复定义的bean在scan的时候跳过。
2.2)base-package路径及其子路径都会被scan
- spring 疑问汇总
- 疑问汇总
- 疑问的汇总
- socket相关疑问汇总!
- Android 疑问汇总
- spring学习疑问
- Spring的疑问若干
- Spring的疑问若干
- Spring的疑问若干
- spring security源代码疑问
- CSS 疑问汇总(1)
- 关于Spring的一些疑问
- spring监听器ContextLoaderListener的疑问
- [使用疑问] 芒果使用问题汇总
- 技术 优化 奇思异想 灵感 疑问 探索汇总
- iOS 中关于Copy的疑问汇总
- java编程思想--学习疑问汇总
- Mysql 常见报错和疑问汇总
- 【求助大神】android游戏按下home后,从任务管理进入游戏黑屏问题
- 安卓仿手机网易新闻app项目开发系列之(四)数据分离与填充界面 下
- 【LeetCode】629. K Inverse Pairs Array
- 快速将多个excel表合并成一个excel表
- 第二章 使用Bootstrap的准备-tab标签小案例 笔记3
- spring 疑问汇总
- LeetCode 98. Validate Binary Search Tree
- PHP扩展及PHP7.0安装
- 活动界面重复返回
- 在ubuntu下编译多个C++文件
- 学习互联网架构第八课(单例和多线程)
- 多个Fragment界面重叠和拍照闪退问题
- NPOI的文件流
- spring中的Cglib字节码增强实现AOP