接手项目改造
老项目持久层使用封装的Hibernate,封装之后巨难用。又不能随便改框架,不然整个项目都跑不起来。
索性在新功能模块中引入Mybatis-Plus
启动报错:Invalid bound statement (not found)
各种原因都是试过,最后通过修改SqlSessionFactory解决
贴代码:
@Bean
public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
return sessionFactory.getObject();
}
参考来源:https://editor.youkuaiyun.com/md?not_checkout=1&spm=1001.2101.3001.4503&articleId=145774958