摘要: ####属性的注入 @Component扫描到bean中,组件的意思,会用在实体类或者映射类上 @Autowired,将已经在bean中的类,引用 @Component //@Component 组件 //等价于<bean id="User" class="com.liu.pojo.User"/> 阅读全文
posted @ 2022-04-21 17:35 小幼虫虫 阅读(78) 评论(0) 推荐(0)
摘要: ###1导入约束 @Autowried用于属性类 导入约束:context约束 开启注解的支持 context:annotation-config/ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframe 阅读全文
posted @ 2022-04-21 16:25 小幼虫虫 阅读(173) 评论(0) 推荐(0)
摘要: ###bean的自动装配 自动是Spring满足bean依赖的一种方式 Spring会在上下文中自动寻找,并自动给bean装配属性 在spring中有3中装配方式 在XML中显式的配置 在java中显式配置 在xml中隐式自动装配 ####在xml中隐式自动装配 <?xml version="1.0 阅读全文
posted @ 2022-04-21 15:24 小幼虫虫 阅读(36) 评论(0) 推荐(0)
摘要: ###bean的作用域 <bean id="User1" class="com.liu.pojo.User" p:age="18" p:name="小明" scope="singleton"></bean> 1、singleton作用域: Spring的scope的默认值是singleton Spr 阅读全文
posted @ 2022-04-21 14:50 小幼虫虫 阅读(67) 评论(0) 推荐(0)
摘要: ####文件头注入2行即可用 xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c" <?xml version="1.0" encoding="UTF-8 阅读全文
posted @ 2022-04-21 14:30 小幼虫虫 阅读(37) 评论(0) 推荐(0)