Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

简介: Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

问题:Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required

原因

mybatis-spring-1.3.2中取消了自动注入SqlSessionFactory 和 SqlSessionTemplate,所以会报出Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required错误。

<dependency>
  <groupId>org.mybatis.spring.boot</groupId>
  <artifactId>mybatis-spring-boot-starter</artifactId>
  <version>1.3.2</version>
</dependency>

解决

方法一:

加上<artifactId>mybatis-spring-boot-starter</artifactId>这个依赖就自动注入

方法二:

把application.properties配置文件改为application.yml

方法三:

在pom.xml加上

<dependency>
  <groupId>com.alibaba</groupId>
  <artifactId>druid-spring-boot-starter</artifactId>
  <version>1.1.9</version>
</dependency>


相关文章
|
Java 数据库连接 mybatis
Consider defining a bean of type ‘com.example.democrud.democurd.usermapper.DaoMapper‘ in your config
Consider defining a bean of type ‘com.example.democrud.democurd.usermapper.DaoMapper‘ in your config
222 0
|
6月前
|
XML 数据格式
Could not autowire. No beans of ‘VideoDao‘ type found.
Could not autowire. No beans of ‘VideoDao‘ type found.
|
Java Apache Spring
解决required a single bean, but 2 were found问题
背景:springboot整合shiro中自定义Realm时出现 错误描述 Parameter 0 of method getDefaultWebSecurityManager in cn.ken.springboot_shiro.config.ShiroConfig required a single bean, but 2 were foun
|
NoSQL Java Redis
一日一技:在什么情况下使用@property比较好?
一日一技:在什么情况下使用@property比较好?
94 0
|
JavaScript 前端开发
|
Java Spring
Could not autowire. No beans of *** type found
Could not autowire. No beans of *** type found
209 0
Could not autowire. No beans of *** type found