配置多数据源抛出的异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
解决方案
将 SqlSessionFactoryBean 替换为 MybatisSqlSessionFactoryBean
产生异常的代码
@Bean @Primary public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); bean.setDataSource(dataSource); // bean.setPlugins(new Interceptor[] {xxx}); // 设置MyBatis插件 return bean.getObject(); }
修改后的方法
@Bean @Primary public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean(); bean.setDataSource(dataSource); // bean.setPlugins(new Interceptor[] {xxx}); // 设置MyBatis插件 return bean.getObject(); }
参考连接
配置多数据源抛出的异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)