随笔都是学习笔记
随笔仅供参考,为避免笔记中可能出现的错误误导他人,请勿转载。
摘要: 一般的方式需要配置bean或ref引用bean,自动注入会自动进行匹配,如果存在则创建。 匹配原则:使用Bean的id属性中的值去和相对应的值匹配 关键词autowire="" default:默认 byType:根据类型自动匹配 byName:根据名字自动匹配 constructor: 根据构造器 阅读全文
posted @ 2022-05-26 17:40 时间完全不够用啊 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 创建一个Child类继承Wife,不写任何内容: package entity;public class Child extends Person{} 然后在Wife类中添加静态方法: /** * 静态工厂方法 * @return */ public static Wife createChild( 阅读全文
posted @ 2022-05-26 16:52 时间完全不够用啊 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 作用域有两种: prototype singleton singleton(单例)(默认为单例): 按照上面的配置 @Test public void fun2(){ System.out.println("begin!"); Wife wife = app.getBean("wife", Wife 阅读全文
posted @ 2022-05-26 16:30 时间完全不够用啊 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 使用的类和配置文件查看: https://www.cnblogs.com/0099-ymsml/p/16309077.html 使用lazy-init=""配置懒加载,配置了懒加载的bean不会随着容器的创建而加载,而是在getBean()获取时才会实例化。 xml配置: <bean class=" 阅读全文
posted @ 2022-05-26 16:12 时间完全不够用啊 阅读(375) 评论(0) 推荐(0) 编辑