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 texas.sbq.travel; import javax.sql.DataSource; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.annotation.MapperScan; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @MapperScan(basePackages= {"texas.sbq.travel.mappers"}) @EnableTransactionManagement public class MybatisConfig { @Bean public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); sessionFactory.setMapperLocations(resolver.getResources("classpath:texas/sbq/travel/mappers/*.xml")); return sessionFactory.getObject(); } @Bean public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory ) throws Exception { final SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory); return sqlSessionTemplate; } } | cs |
'프로젝트 > 스프링 & 타임리프' 카테고리의 다른 글
40. 질병관리 :: 관리자 등록 프로세스 HTML -> Java -> csv (0) | 2020.04.29 |
---|---|
40. 질병관리 :: 관리자 등록 템플릿 register.html (0) | 2020.04.28 |
40. 질병관리 :: 홈 화면 index.html 템플릿 (0) | 2020.04.28 |
40. 질병관리 :: 최초 index.html ※ 템플릿 사용하지 않고 쉽게 시작하기 (0) | 2020.04.17 |
37. 여행 :: HomeController.java & @Controller 활용한 화면이동 소스코드 (0) | 2020.03.24 |