springBoot+mybatis报错Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required

springBoot+mybatis报错Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required报错为:Invocationofinitmethodfailed;nestedexceptionisjava.lang.IllegalArgumentException:Property’sqlSessionFactory’or’sqlSessionTemplate’arerequired日志很长,报错在末尾2018-07-1213:56:41.760 I…

大家好,又见面了,我是你们的朋友全栈君。

报错为:Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required

日志很长,报错在末尾

2018-07-12 13:56:41.760  INFO 9476 — [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.16

2018-07-12 13:56:42.040  INFO 9476 — [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-12 13:56:42.041  INFO 9476 — [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4259 ms
2018-07-12 13:56:42.057  WARN 9476 — [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.061  WARN 9476 — [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.096  WARN 9476 — [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.101  WARN 9476 — [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.163  WARN 9476 — [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.168  WARN 9476 — [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.394  INFO 9476 — [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: ‘dispatcherServlet’ to [/]
2018-07-12 13:56:42.402  INFO 9476 — [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘characterEncodingFilter’ to: [/*]
2018-07-12 13:56:42.402  INFO 9476 — [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘hiddenHttpMethodFilter’ to: [/*]
2018-07-12 13:56:42.403  INFO 9476 — [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘httpPutFormContentFilter’ to: [/*]
2018-07-12 13:56:42.403  INFO 9476 — [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘requestContextFilter’ to: [/*]
2018-07-12 13:56:42.459  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.471  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.476  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.481  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.485  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.548  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.557  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.564  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.570  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.577  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:42.581  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.603  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.606  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.612  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.622  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.623  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.625  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.637  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.647  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.653  WARN 9476 — [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.655  WARN 9476 — [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘brokenOrderMsgListener’: Unsatisfied dependency expressed through field ‘orderManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘orderManager’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘org.apache.ibatis.session.SqlSessionFactory’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=sqlSessionFactory)}
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘*****OrderMapper’ defined in file [E:\GIT_workspace\inas-***-server\target\classes\com\****\***\***\dao\*****OrderMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
2018-07-12 13:56:43.658  INFO 9476 — [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-07-12 13:56:43.693  INFO 9476 — [           main] utoConfigurationReportLoggingInitializer : 
Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled.
2018-07-12 13:56:43.804 ERROR 9476 — [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************
Description:
Field orderManager in com.****.***.***.listener.MsgListener required a bean of type ‘org.apache.ibatis.session.SqlSessionFactory’ that could not be found.
Action:

Consider defining a bean of type ‘org.apache.ibatis.session.SqlSessionFactory’ in your configuration.

 

Consider defining a bean of type ‘org.apache.ibatis.session.SqlSessionFactory’ in your configuration.

 

1.缺少jar包引起

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

引入jar包后问题解决

2.未解决再添加(DaoImpl

extends SqlSessionDaoSupport )
import org.mybatis.spring.support.SqlSessionDaoSupport;

 

@Override
@Resource
public void setSqlSessionFactory(@Qualifier("sqlSessionFactory")SqlSessionFactory sqlSessionFactory){
    super.setSqlSessionFactory(sqlSessionFactory);
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/138698.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • docker安装Lefse和分析流程[通俗易懂]

    docker安装Lefse和分析流程[通俗易懂]linux通过docker安装lefse默认你已经安装好docker!下载lefse镜像文件dockerrun-itbiobakery/lefsebash启动docker的lefse镜像,并且把主机文件夹挂载到镜像,这样可以在镜像中看到主机中的文件夹,下面是吧主机中的Data文件夹挂在到镜像(shared文件夹需要自己建),更改Data权限shared权限也会改变…

  • linux 挂载磁盘阵列[通俗易懂]

    linux 挂载磁盘阵列[通俗易懂]1、fdisk-l查看磁盘系统磁盘,若提示bash:fdisk:commandnotfound这是因为fdisk没有在搜索路径中,我们需要:#echo$PATH/usr/kerberos/sbin再查看fdisk命令再哪个目录下:#whereisfdiskfdisk:/sbin/fdi…

  • android 封装网络框架(java企业自己封装的框架)

    Android网络框架OKGo封装本文讲述了Android网络框架OKGo封装,封装的框架适用于项目当中,适合新手操作,OKGO框架本身就以简单易上手而深受喜欢,而此文就是基于框架之上再次封装,废话不多说,直接开始吧!首先在我们的build.gradle中导入我们引用的框架dependencies{…implementation’com.lzy.net:okgo:3.0.4’i…

  • 哥哥[通俗易懂]

    哥哥[通俗易懂]哥哥

  • WebAssembly完全入门——了解wasm的前世今身

    WebAssembly完全入门——了解wasm的前世今身前言接触WebAssembly之后,在google上看了很多资料。感觉对WebAssembly的使用、介绍、意义都说的比较模糊和笼统。感觉看了之后收获没有达到预期,要么是文章中的例子自己去实操不能成

  • JRTPLIB使用实例

    JRTPLIB使用实例这几天在看关于JRTPLIB方面的东西。在网上看了不少文章,其中有很大部分使用的JRTPLIB版本在3.0以下。在网上下载了一个JRTPLIB-3.7的库,发现里面的函数接口做了一些修改。现奉上一篇基

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号