MybatisPlus的配置
记录一下项目使用到的配置文件
@Configuration public class MybatisPlusConfiguration { @Autowired private DataSource dataSource; @Autowired private MybatisProperties properties; @Autowired private ResourceLoader resourceLoader = new DefaultResourceLoader(); @Autowired(required = false) private Interceptor[] interceptors; @Autowired(required = false) private DatabaseIdProvider databaseIdProvider; /** * @desc mybatis-plus的分页插件 * @return */ @Bean public PaginationInterceptor paginationInterceptor(){ PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); paginationInterceptor.setDialectType("oracle"); return paginationInterceptor; } @Bean public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean(){ MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean(); mybatisPlus.setDataSource(dataSource); mybatisPlus.setVfs(SpringBootVFS.class); if(StringUtils.hasText(this.properties.getConfigLocation())){ mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); } mybatisPlus.setConfiguration(properties.getConfiguration()); if(!ObjectUtils.isEmpty(this.interceptors)){ mybatisPlus.setPlugins((org.apache.ibatis.plugin.Interceptor[]) this.interceptors); } MybatisConfiguration mc = new MybatisConfiguration(); mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class); mybatisPlus.setConfiguration(mc); if (this.databaseIdProvider != null){ mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider); } if(StringUtils.hasLength(this.properties.getTypeAliasesPackage())){ mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); } if(StringUtils.hasLength(this.properties.getTypeHandlersPackage())){ mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage()); } if(!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())){ mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations()); } return mybatisPlus; } }