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 import java.util.Objects;
29
30 @Configuration
31 @MapperScan("examples.column.comparison")
32 public class ColumnComparisonConfiguration {
33 @Bean
34 public DataSource datasource() {
35 return new EmbeddedDatabaseBuilder()
36 .setType(EmbeddedDatabaseType.HSQL)
37 .generateUniqueName(true)
38 .addScript("classpath:/examples/column/comparison/CreateDB.sql")
39 .build();
40 }
41
42 @Bean
43 public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
44 SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
45 factoryBean.setDataSource(dataSource);
46 return Objects.requireNonNull(factoryBean.getObject());
47 }
48 }