多数据源配置报错:Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
时间: 2023-08-27 09:20:26 浏览: 964
Spring3 整合MyBatis3 配置多数据源动态选择SqlSessionFactory详细教程
这个错误是由于缺少必要的属性'sqlSessionFactory'或'sqlSessionTemplate'引起的。这个错误通常在配置多数据源时出现。在Spring Boot中,当我们使用MyBatis整合时,我们需要配置每个数据源的'sqlSessionFactory'或'sqlSessionTemplate'属性。这两个属性是用来创建SqlSession的工厂或模板,它们是访问数据库的核心组件。如果我们没有正确配置它们,就会导致这个错误。所以,解决这个问题的方法是在配置文件中为每个数据源添加正确的'sqlSessionFactory'或'sqlSessionTemplate'属性配置。这样,Spring Boot就能够正确地创建SqlSession实例并访问数据库了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [springboot整合mybatis的时候报错Caused by: java.lang.IllegalArgumentException: Property '...](https://blog.csdn.net/weixin_30297281/article/details/101442749)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [plus报错 Caused by: java.lang.IllegalArgumentException: Property ‘sqlSessionFactory‘ or ‘sql](https://blog.csdn.net/qq_38329894/article/details/120195256)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [springcloud提示Caused by: java.lang.IllegalArgumentException: Property ‘sqlSessionFactory‘ or ...](https://blog.csdn.net/qq_37844454/article/details/114419084)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文