Spring bean

1.Spring bean


1)编写各个实体类
Java 各个类,描述对象

2)声明spring的配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>

3)在spring配置文件中,配置各个实体类(bean)
<beans ...>
<!-- 配置各个实体类,常用属性 -->
<!-- bean的配置,id 在容器中的唯一标识;class 实体类的位置路径;ref="" 容器中的bean 的引用,值为bean 的id; -->
<bean id="" class="">
<!-- bean 的属性配置;配置实体类成员变量的值,name 是实体类的属性名(成员变量),value 是属性的值,ref 是对bean 的引用(与value互斥); -->
<property name="" value="" ref=""></property>
</bean>
</beans>

posted on 2017-06-30 10:13  darkcode  阅读(134)  评论(0编辑  收藏  举报