---
title: "Spring简单属性注入"
author: "kingge08"
date: "2011-06-03T19:51:05Z"
tags: []
categories: ["企业架构"]
slug: "spring"
draft: false
lastmod: "2011-06-03T19:51:39Z"
id: 1069875
url: "https://wwwzchen.iteye.com/blog/1069875"
---

```
package com.zchen.property;

public class User {
	private int id;
	private String name;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	

}
```

 

```
<?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="user" class="com.zchen.property.User">
  	<property name="id" value="2" />
  	<property name="name" value="zchen" />
  </bean>
</beans>
```