@Configuration
/* @MapperScan(basePackages="com.bit.paperhouse.dao") */
@EnableTransactionManagement
public class DatabaseConfig {
//데이터베이스 경로설정
@Bean
public SqlSessionFactory sqlSessionFactory( DataSource dataSource ) throws Exception {
System.out.println("DatabaseConfig SqlSessionFactory");
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
Resource[] arrResource = new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml");
sqlSessionFactoryBean.setMapperLocations(arrResource);
sqlSessionFactoryBean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
return (SqlSessionFactory)sqlSessionFactoryBean.getObject();
}
@Bean
public SqlSessionTemplate sqlSession( SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}