JAVA中的Spring,不明白是什么意思~~晕.....

来源:百度知道 编辑:UC知道 时间:2024/05/18 08:15:09
刚学Spring,老师给出了到题,可是不知道到底是什么意思,请大家帮帮我。。。要是能帮我写点代码的话,那我真的感激不尽啦。。。。
编写一个Java应用,要求如下:
1. 两个Java类:
1) 学生类(Student)
该类有如下几个属性:年龄(age)、姓名(name)、爱好(intrest)、地址(address)等
其中地址(address)属性类型为地址类。
2) 地址类(Address)
该类有如下几个属性:邮编(zipcode)、地址(address)、联系电话(phone)等
2. 使用Spring框架管理Java对象,Student对象的地址(address)属性使用注入方式进行管理
3. 编写演示代码,演示Student对象的地址等有关属性
4. 代码中要有相应的注释

2。首先Spring有三种注入方式借口,设值,构造子,我用的是设值
先写好你的Student、address类的bean文件
<?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-2.5.xsd">
<bean id="address" class="bean.Address">
<property name="zipcode" value="你想要写的值"></property>