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 32
|
@Configuration @MapperScan(basePackages = "cn.edu.nju.fintech4good.dao.FinTech4Good", sqlSessionFactoryRef = "FinTech4GoodSessionFactory") public class FinTech4GoodConfig { @Bean(name = "FinTech4GoodDatabase") @Primary @ConfigurationProperties(prefix = "spring.datasource.fintech4good") public DataSource getDateSource() { return DataSourceBuilder.create().build(); }
@Bean(name = "FinTech4GoodSessionFactory") @Primary public SqlSessionFactory FinTech4GoodSessionFactory(@Qualifier("FinTech4GoodDatabase") DataSource datasource) throws Exception { SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); bean.setDataSource(datasource); bean.setVfs(SpringBootVFS.class); bean.setMapperLocations( new PathMatchingResourcePatternResolver().getResources("classpath:dataImpl/FinTech4Good/*Mapper.xml")); return bean.getObject(); }
@Bean("FinTech4GoodSqlSessionTemplate") @Primary public SqlSessionTemplate FinTech4GoodSqlSessionTemplate( @Qualifier("FinTech4GoodSessionFactory") SqlSessionFactory sessionfactory) { return new SqlSessionTemplate(sessionfactory); } }
|