1.创建用户实体类

[]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package entity;

import java.util.List;

public class User {
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public List<String> getHobby() {
return hobby;
}

public void setHobby(List<String> hobby) {
this.hobby = hobby;
}

String name;
int age;
List<String> hobby;
}

2.Beans的编写

[]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<bean id="user" class="entity.User">
<property name="name">
<value>fanxing</value>
</property>
<property name="age">
<value>18</value>
</property>
<property name="hobby">
<list>
<value>game</value>
<value>code</value>
</list>
</property>
</bean>

3.如何运行

[]
1
2
3
4
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("你的applicationContext.xml所在的位置");
User ts = (User)context.getBean("user", User.class);
}
更新于

请我喝[茶]~( ̄▽ ̄)~*

Fanxing 微信支付

微信支付

Fanxing 支付宝

支付宝

Fanxing 贝宝

贝宝