摘要:
spring中FactoryBean类的用法 1、简介 工厂bean,它是作用主要就是创建bean对象 2、如何使用 2.1、编写实体类 package com.yl.bean; public class Car { private String brand; private Integer pri 阅读全文
摘要:
spring基于xml导入配置文件 在原先的bean的xml配置文件导入另外的bean xml配置文件,都受同一个IOC容器的管理及配置 用法 <!--导入bean1.xml文件的内容--> <import resource="bean1.xml" /> 阅读全文
摘要:
spring中bean的继承和依赖关系 1、bean之间的继承 将公共的配置写到父bean,子bean直接继承即可使用 举例 定义一个父bean <!--实现bean之间的继承关系--> <bean id="parentCar" class="com.gec.bean.Car" > <propert 阅读全文
摘要:
spring整合junit 首先准备好spring项目,新建spring项目可以参考以下资料 spring基于xml配置入门案例 spring注解入门案例 spring纯注解案例 这里就不再阐述怎么新建spring项目了,准备好spring项目环境之后,就可以开始spring整合junit了 1、导 阅读全文
摘要:
spring新注解说明 @Configuration、@ComponentScan在纯注解案例中已经说明,就不再阐述;这里主要讲一下@PropertySource、@Import、@Bean 1、@PropertySource 作用:用于加载.properties文件中的配置。例如我们配置数据源时, 阅读全文
摘要:
spring纯注解案例 我们发现,之所以我们现在离不开xml配置文件,是因为我们有一句很关键的配置: <!-- 告知spring框架在,读取配置文件,创建容器时,扫描注解,依据注解创建对象,并存入容器中 --> <context:component-scan base-package=**"com. 阅读全文
摘要:
spring常用注解的使用 1、用于创建对象 相当于: 1.1、@Component 作用:把资源让spring来管理,相当于在xml中配置一个bean。 属性 value:指定bean的id;如果不指定value属性,默认bean的id是当前类的类名,首字母小写。 1.2、@Controller、 阅读全文
摘要:
spring注解入门案例 基于maven项目 1、准备jar包 <!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> <dependency> <groupId>org.springframewo 阅读全文