可以简化set注入
【1】在xml中设置xmlns:p=http/www.springframework.org/schema/p
【2】配置bean
可以简化构造注入
【1】在xml中设置xmlns:c=http/www.springframework.org/schema/c
【2】配置bean
【1】在xml中设置
xmlns util=http/www.springframework.org/schema/util
xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-xsd"
【2】配置bean
... ... ... ...
自动装配是基于set方法的,因此若是有参构造方法,可能会产生错误
【1】在service类中写setOrder()方法
【2】在xml文件中配置autowere="byName"和id="order"
注意:id的名字为set方法中的实体名(首字母小写)
【1】在service类中写setOrder()方法
【2】在xml文件中配置autowere="byName",根据类型装配的话,bean 不用写id属性,因为在配置文件中,某种类型的实例只能有一个
【1】在xml文件中引入context命名空间
【2】使用标签context:property-placeholder location=“xxx.properties”