본문 바로가기
springframework

spring+mybatis 환경설정 -4

by blog-yj 2019. 1. 17.

MyBatis 연결 테스트



@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(

locations= {"file:src/main/webapp/WEB-INF/spring/**/root-context.xml"})

public class MYSQLTest {

@Inject

private SqlSessionFactory sqlFactory;

@Test

public void test() {

System.out.println(sqlFactory);

}

@Test

public void testSession() throws Exception{

try(SqlSession session=sqlFactory.openSession()) {

System.out.println(session);

} catch (Exception e) {

e.printStackTrace();

}

}

}