![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
spring
文章平均质量分 78
qq_44209563
这个作者很懒,什么都没留下…
展开
-
注解注入方式
一、注解分类与XML配置对比:<bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl" scope="" init-method="" destroy-method=""> <property name="" value="" / ref=""...原创 2019-11-12 21:37:28 · 1211 阅读 · 0 评论 -
依赖注入
一、注入的方式使用构造函数使用set方法使用注解二、能注入三类数据:1、基本类型和String2、其他bean类型(在配置文件或注解配置过的bean)3、复杂类型/集合类型1、构造函数注入:使用constructor-arg标签,出现在bean标签内部。属性:type:用于指定要注入的数据的数据类型,该数据类型也是构造函数中某个或某些参数的类型index:用于指定要...原创 2019-11-12 19:06:10 · 75 阅读 · 0 评论 -
Spring整合junit
一、需求由于在使用测试包时,里边的测试方法每次使用都需要首先获取容器对象,再调用方法getBean()来得到想要的对象,因此想将重复获取容器对象的代码省略做法:在类中定义一个IAccountService类型的属性,使用注解方法注入,但是存在一些问题二、问题分析1、应用程序入口main方法2、junit单元测试中,没有main方法也能执行junit集成了一个main方法,该方法会...原创 2019-11-13 17:33:17 · 100 阅读 · 0 评论 -
编写spring配置案例
一、单表操作简单案例jar包依赖: <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> ...原创 2019-11-13 16:48:35 · 93 阅读 · 0 评论 -
Spring对bean的管理细节
一、创建bean的三种方式文件结构如下:1、方式一:在使用容器对象调用getBean(“accountService”)时,容器会使用AccountServiceImpl类中的无参构造方法来创建对象。2、方式二:InstanceFactory类中的内容:使用容器对象调用getBean(“AccountService”)获取AccountServiceImpl对象,配置文件中的内...原创 2019-11-12 14:01:56 · 115 阅读 · 0 评论