Description:
Field sessionTemplate in com.xxx.common.BaseDaoImpl required a bean of type 'org.mybatis.spring.SqlSessionTemplate' that could not be found.
- Bean method 'sqlSessionTemplate' not loaded because @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) did not find any beans of type javax.sql.DataSource
Action:
Consider revisiting the entries above or defining a bean of type 'org.mybatis.spring.SqlSessionTemplate' in your configuration.
springBoot自动注入时出错,查了一下,是因为我在application中加了exclude = DataSourceAutoConfiguration.class导致的,删掉后就可以了,如果还不能启动,再加上@ComponentScan(basePackages = "com.xxx.*")就可以了
本文解决了一个关于Spring Boot项目中MyBatis整合时出现的问题,即无法找到SqlSessionTemplate bean的情况。问题根源在于配置中排除了数据源自动配置,通过移除排除项并添加组件扫描解决了该问题。
1271

被折叠的 条评论
为什么被折叠?



