(3)Spring 测试搭建环境

1.相关.jar包说明 *注:所有的文章基于Spring 2.5.6

dist/spring.jar
lib/jakarta-commons/commons-logging.jar
如果使用了切面编程(AOP),还需要下列jar文件
lib/aspectj/aspectjweaver.jar和aspectjrt.jar
lib/cglib/cglib-nodep-2.1_3.jar
如果使用了JSR-250中的注解,如@Resource/@PostConstruct/@PreDestroy,还需要下列jar文件
lib/j2ee/common-annotations.jar

 

2.myeclipse8.5 建立项目如图

 

(3)Spring 测试搭建环境_第1张图片

 

beans.xml

<?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"> </beans>

SpringTest.java

package junit.test; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class SpringTest { @BeforeClass public static void setUpBeforeClass() throws Exception { } @Test public void instanceSpring() { //可以装载多个xml文件 //ApplicationContext context = new ClassPathXmlApplicationContext(new String []{"beans.xml"}); ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); } }

 

测试显绿条则说明Spring 环境搭建成功!

 

 

你可能感兴趣的:(spring,AOP,exception,测试,jar,encoding)