spring很早就更新了3.0版本,可是由于项目要求稳定,却一直没有使用到,最近有个新项目,打算采用spring3了。
项目整个结构如下:
1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:p="http://www.springframework.org/schema/p"
5 xsi:schemaLocation="http://www.springframework.org/schema/beans
6 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
7
8 <bean id="dao" class="Dao"/>
9
10 </beans>
1
2 public class Dao {
3 public void find() {
4 System.out.println("dao: find()");
5 }
6 }
7
1 import org.springframework.context.ApplicationContext;
2 import org.springframework.context.support.ClassPathXmlApplicationContext;
3
4 public class Client {
5
6 public static void main(String[] args) {
7 ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
8 Dao dao = context.getBean(Dao.class);
9 dao.find();
10 }
11 }
12