1. 程式人生 > >ssm整合測試資料庫是否連結成功

ssm整合測試資料庫是否連結成功

方法一.在TestDataSource .java測試

public class TestDataSource {



@SuppressWarnings("resource")
@Test
public void testDataSources() throws SQLException{
 
ApplicationContext ac = null;
{
ac = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
}
DataSource dataSource=ac.getBean(DataSource.class);
System.out.println(dataSource.getConnection());
}
}