1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | package kr.co.silver.board; import java.sql.Connection; import javax.inject.Inject; import javax.sql.DataSource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/**/root-context.xml" }) public class DataSourceTest { @Inject private DataSource ds; /** * @throws Exception */ @Test public void testConnection() throws Exception { try (Connection con = ds.getConnection()) { System.out.println(con); } catch (Exception e) { e.printStackTrace(); } } } | cs |
'TIP > SPRING' 카테고리의 다른 글
web.xml(3.0)한글 처리 포함 (0) | 2018.10.10 |
---|---|
mybatis test 코드 (0) | 2018.10.10 |
pom.xml 최종 (0) | 2018.10.10 |
mapper.xml (0) | 2018.10.10 |
mybatis-config.xml (0) | 2018.10.10 |