1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package examples.column.comparison;
17
18 import javax.sql.DataSource;
19
20 import org.apache.ibatis.session.SqlSessionFactory;
21 import org.mybatis.spring.SqlSessionFactoryBean;
22 import org.mybatis.spring.annotation.MapperScan;
23 import org.springframework.context.annotation.Bean;
24 import org.springframework.context.annotation.Configuration;
25 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
26 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
27
28 @Configuration
29 @MapperScan("examples.column.comparison")
30 public class ColumnComparisonConfiguration {
31 @Bean
32 public DataSource datasource() {
33 return new EmbeddedDatabaseBuilder()
34 .setType(EmbeddedDatabaseType.HSQL)
35 .generateUniqueName(true)
36 .addScript("classpath:/examples/column/comparison/CreateDB.sql")
37 .build();
38 }
39
40 @Bean
41 public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
42 SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
43 factoryBean.setDataSource(dataSource);
44 return factoryBean.getObject();
45 }
46 }