-
@author lanys
-
@Description:
-
@date 23/7/2021 下午8:38
*/
@Configuration
@EnableTransactionManagement
@PropertySource(value = “classpath:application.yml”, ignoreResourceNotFound = true)
public class MybatisConfig implements TransactionManagementConfigurer {
@Value("${mybatis.mapper-locations}")
private String mapper;
@Value("${mybatis.type-aliases-package}")
private String aliases;
@Autowired
private DataSource dataSource;
@Bean(name = “sqlSessionFactory”)
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
// 设置数据源
bean.setDataSource(dataSource);
// 设置xml
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(map