010 問題:Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
阿新 • • 發佈:2022-05-28
錯誤提示:
java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [D:\java\store\store\target\classes\com\cy\store\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
翻譯:
原因是mybatis-spring-1.3.2中取消了自動注入SqlSessionFactory 和 SqlSessionTemplate,也就是mybatis依賴版本的問題。
解決辦法:
自己的解決辦法:
缺少了mybatis-spring-boot-starter
maven中
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency>