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>


相关文章
|
6月前
|
Java 数据库连接 Spring
spring配合hibernate报错:sessionFactory or hibernateTemplate is required
根据你的具体情况,检查上述步骤中的一个或多个,以确定为何出现“sessionFactory or hibernateTemplate is required”错误,并采取相应的措施进行修复。 买CN2云服务器,免备案服务器,高防服务器,就选蓝易云。百度搜索:蓝易云
53 0
|
Java 数据库连接 mybatis
There is no getter for property named ‘null‘ in ‘class
There is no getter for property named ‘null‘ in ‘class
182 0
There is no getter for property named ‘null‘ in ‘class
|
Java 编译器
解决NoSuchBeanDefinitionException: No qualifying bean of type ‘bean.User‘ available
解决NoSuchBeanDefinitionException: No qualifying bean of type ‘bean.User‘ available
180 0
|
Java 数据库连接 Spring
spring整合 mybatis时 SqlSessionFactoryBean的一个小报错:Bean named ‘sqlSessionFactory‘ is expected to be of ty
spring整合 mybatis时 SqlSessionFactoryBean的一个小报错:Bean named ‘sqlSessionFactory‘ is expected to be of ty
392 0
|
NoSQL Java Redis
一日一技:在什么情况下使用@property比较好?
一日一技:在什么情况下使用@property比较好?
88 0
|
Java 数据库连接 mybatis
mybatis:There is no getter for property named ‘REGION‘ in ‘xxxEntity‘
mybatis:There is no getter for property named ‘REGION‘ in ‘xxxEntity‘
167 0
mybatis:There is no getter for property named ‘REGION‘ in ‘xxxEntity‘