@Bean(name = "sqlSessionFactory.xx")
public SqlSessionFactory sqlSessionFactory(@Qualifier("datasource.motorbike") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSource);
org.apache.ibatis.session.Configuration configuration = new MybatisConfiguration();
//读取null值设置
configuration.setCallSettersOnNulls(true);
bean.setConfiguration(configuration);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
bean.setMapperLocations(resolver.getResources("classpath:mapper/xx/*.xml"));
return bean.getObject();
}
注意标红这俩对象,都要使用MyBatis-Plus提供的类