Spring4 笔记】的更多相关文章

<?xml version="1.0" encoding="GBK"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p&qu…
package com.ij34.bean; import java.util.Iterator; import java.util.List; import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.io.SAXReader; import org.springframework.core.io.UrlResource; public class UrlResourceTest { public static…
init-method : 指定bean的初始化方法-spring容器会在bean的依赖关系注入完成后调用该方法 destroy-method :指定bean销毁之前的方法-spring容器将会在销毁该bean之前调用该方法 @PostConstruct :bean的初始化方法 @PreDestroy  :bean销毁之前的方法…
@Component  :标注一个普通的Spring Bean类 @Controller    :标注一个控制器组件器 @Service        :标注一个业务逻辑组件器 @Repository   :标注一个DAO组件类 在默认的情况之下,spring会自动的搜索所有上面的标注的java类,并把它们当成Spring Bean处理 spring3.0 @DependsOn  :用于强制初始化其他bean  @DependsOn({"chinese","usa"…
driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/spring username=root password=123456 <!-- --------PropertyOverrideConfigurer ------------------ dataSource.driverClass=com.mysql.jdbc.Driver dataSource.jdbcUrl=jdbc:mysql://localho…
PropertyPlaceholderConfigurer  属性占位符配置器 PropertyOverrideConfigureer    重写占位符配置器 CustomAutowireConfigurer      自定义自动装配的配置器 CustomScopeConfigurer          自定义作用域的配置器…
private List<String> schools; <property name="schools"> <list> <value>小学</value> <value>中学</value> <value>大学</value> </list> </property> private Map scores; <property name=&quo…
no :不自动装配 byName :id(name)与setter方法去set前缀,并小写首字母后同名的Bean完成注入,如有多个匹配则抛异常 byType :spring容器找全部bean,如果找到单单一个bean类型和setter方法形参类型匹配的则完成注入,如有多个匹配则抛异常 两个名字相同抛异常情况例子: Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionPars…
设值注入:通过<property.../>元素驱动Spring执行setter的方法 构造注入:通过<constructor-arg.../>元素驱动Spring执行带有参数的构造器 两者都视为对Bean的依赖和接受Spring容器的管理 依赖关系的值一般是一个确定的值或者Spring容器中其他Bean的引用…