1.建一个java web工程项目,名字是:blog.youkuaiyun.com.daliu
2.建俩个包,一个名字是org.spring.dao,另外一个是:org.spring.test
3.导入相应的jar包。可以在这里下载到相对应的包:
http://pan.baidu.com/s/1jf5sq
完整代码如下:
5.在org.spring.test 下新建testCase.java文件,用于测试。
2.建俩个包,一个名字是org.spring.dao,另外一个是:org.spring.test
3.导入相应的jar包。可以在这里下载到相对应的包:
http://pan.baidu.com/s/1jf5sq
如下图:
完整代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd">
</beans>
5.在org.spring.test 下新建testCase.java文件,用于测试。
完整代码如下:
package org.spring.test;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class testCase {
@Test
public void test() {
String config = "applicationContext.xml";
ApplicationContext ac = new ClassPathXmlApplicationContext(config);
System.out.println(ac);
}
}
在控制台出现以下的提示,说明配置成功!!