spring02-2中bean的装配方式

spring中bean的装配方式一共有三种

  1. 基于xml的装配
  2. Annotation注解:
  3. 隐式的bean发现机制和自动装配。

在这里插入图片描述
这个图不错,出自:https://blog.csdn.net/qq_39411607/article/details/79631484
ps:这篇文章写得也不错。

在这里插入图片描述
还是上面那位仁兄的。

我们重点讲bean的第三种装配方式:自动装配
。。。。。。
很尴尬,找到一篇不错的文章
https://blog.csdn.net/u010142437/article/details/80884972
不过不知道怎么用,以后再看一下

还有一个高级的
是引用外部资源文件
核心类:PropertyPlaceholderConfigurer

public class Dog {
	private String name;
	private Integer age;
}
还有各种构造、setter、getter方法,toString方法等

使用:
新建 dog.properties 资源配置文件

name=jackage
<!-- 加载外部资源文件 -->
<bean  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
	<property name="locations">
		<list>
			<value>classpath:com/test/dog.properties</value>
		</list>
	</property>
</bean>

恩,就是这样

END

猜你喜欢

转载自blog.csdn.net/qq_37989076/article/details/88639823
今日推荐