JUnit-----测试专用
导入jar包: 项目右键---->build path----->add libraries---->JUnit4
测试类:
package org.school.test; import java.sql.SQLException; import javax.sql.DataSource; import org.junit.BeforeClass; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Test { private static ApplicationContext ac; @BeforeClass public static void before() { ac = new ClassPathXmlApplicationContext("app1.xml"); } @org.junit.Test public void test1() throws SQLException { //DataSource dataSource = ac.getBean("dataSource", DataSource.class); //System.out.println(dataSource.getConnection()); } }

浙公网安备 33010602011771号