@青苗 你好,想跟你请教个问题:
mybatis-plus 和Spring Boot 能集成么?咋集成?有具体的例子么?
mybatisplus-spring-boot
mybatisplus-spring-mvc
xxConfig.java
@Bean @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public SqlSessionFactory getMybatisSqlSessionFactoryBean(DataSource myDs) throws Exception { MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean(); factoryBean.setDataSource(myDs); ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver(); factoryBean.setTypeAliasesPackage("com.xb.persistent"); Resource[] resources = resolver.getResources("classpath:/com/xxxx/persistent/mapper/*.xml"); factoryBean.setMapperLocations(resources); factoryBean.setCache(null); PageHelper pageHelper = new com.github.pagehelper.PageHelper(); Properties p = new Properties(); p.setProperty("dialect", "mysql"); pageHelper.setProperties(p); factoryBean.setPlugins(new Interceptor[]{pageHelper}); return factoryBean.getObject(); } @Bean public MapperScannerConfigurer getMapperScannerConfigurer() { MapperScannerConfigurer scanConf = new MapperScannerConfigurer(); scanConf.setBasePackage("com.xxxx.persistent.mapper"); return scanConf; }
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
mybatisplus-spring-boot
mybatisplus-spring-mvc
xxConfig.java