前言

声明:这个错误只是作者在学习时候的一种情况,并不一定能够解决所有情况。还望各位审视出错具体环境!谢谢。
今天使用mybatis逆向工程 springboot本想着少写点代码,但被个bug纠缠到死。bug主要信息为:
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
。。。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]:xxxxxx
。。。

  1. 首先有一个其他原因就是版本不一致:mysql的jar包版本和mysql版本要一致。用的jar包不同出来的东西不同也会出错(亲测)
  2. 其次逆向每次生成要把上一次剩余的删除干净再生成,我每次剩部分就会报错
  3. 我出现这个问题的主要原因是注入失败,失败的原因是mapper.java和mapper.xml不一致,确切的来说是我没配置好使得mapper.xml多了mapper.java没有的内容。思路如下

首先一点是mybatis逆向工程生成的Mapper.java要加@Mapper注解才行,但是加了注解还是会报类似的错,那么我根据我的节奏剖析原因。

  1. 我想使用逆向工程生成一些代码普通最后一项配置是这样的<table tableName="campus" domainObjectName="campus"></table>
  2. 但是逆向工程生成example类我不想要。于是就改了一下
<!---->
<table tableName="campus"
domainObjectName="campus"
enableUpdateByExample="false"
enableSelectByExample="false"
enableDeleteByExample="false"
enableCountByExample="false"></table>

本来以为完好,打开mapper.xml发现两者数量根本不匹配,在xml文件中重复了。

然后我再逆向的xml中添加一行selectByExampleQueryId="false"这个怪我当时参数没写全

 <table tableName="campus" domainObjectName="campus" selectByExampleQueryId="false"enableUpdateByExample="false" enableSelectByExample="false" enableDeleteByExample="false" enableCountByExample="false"></table>

启动就没问题了
这个可能只是这种错误的一小部分,可能帮不到很多人!还有其他情况解决欢迎留言补充!
附带maven版本

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.3.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com</groupId><artifactId>volunteer</artifactId><version>0.0.1-SNAPSHOT</version><name>volunteer</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-core</artifactId><version>1.3.2</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-pool2</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>1.3.2</version></dependency><!--<dependency>--><!--<groupId>org.springframework.boot</groupId>--><!--<artifactId>spring-boot-starter-data-redis</artifactId>--><!--</dependency>--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.46</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><resources><resource><directory>src/main/resources</directory></resource><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes><filtering>true</filtering></resource></resources><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
  • 如果对后端、爬虫、数据结构算法等感性趣欢迎关注我的个人公众号交流:bigsai

Springboot mybatis逆向工程org.springframework.beans.factory.BeanCreationException: Error creating bean错误相关推荐

  1. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManage

    1.错误原因(异常描述) org.springframework.beans.factory.BeanCreationException: Error creating bean with name ...

  2. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 's

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 's ...

  3. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name

    spring boot 启动报错 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating ...

  4. 使用JPA进行update操作时,报org.springframework.beans.factory.BeanCreationException: Error creating bean with

    使用JPA进行update操作时,报org.springframework.beans.factory.BeanCreationException: Error creating bean with ...

  5. org.springframework.beans.factory.BeanCreationException: Error creating bean with name

    严重: Exception sending context initialized event to listener instance of class org.springframework.we ...

  6. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 't

    1.  今天在做redis的时候,爆出这样的错误: Caused by: org.springframework.beans.factory.BeanCreationException: Error ...

  7. 【终极办法】org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘helloC

    报错信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloC ...

  8. “org.springframework.beans.factory.BeanCreationException: Error creating bean with name xxx“问题解决

    问题描述 在本地跑项目的时候出现报错信息: org.springframework.beans.factory.BeanCreationException: Error creating bean w ...

  9. springboot启动报org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean..

    这是一个非常常见一个没有注入bean的错误 报错情况如下 org.springframework.beans.factory.UnsatisfiedDependencyException: Error ...

最新文章

  1. ProcessDialogKey 方法实现回车自动换行
  2. 20190318-使用类做一个简单的图书馆管理系统
  3. [云炬创业基础笔记] 第四章测试5
  4. OpenGL在frag着色器中模拟手电筒效果
  5. Java中创建数组的几种方法
  6. Solaris是出色的Java开发平台的原因
  7. Ubuntu 下无法Tab键自动补全功能解决办法
  8. 常见花材的固定的方法有哪些_固定无梁拱形屋顶的方法都有哪些呢?
  9. C语言练习:第二大整数
  10. matlab优化工具箱安装,MATLAB优化工具箱 OPTI的安装
  11. 计算机一级题库百度云0,全国计算机等级考试一级题库完整.pdf
  12. php相册照片批量修改,php如何实现批量修改文件名称
  13. 使用流程图描述程序的功能与流程
  14. 诡异大阳飙升动因何在
  15. (附源码)计算机毕业设计SSM教师教学质量评价系统
  16. [bowtie2, libtbb.so.2]error while loading shared libraries: libtbb.so.2: cannot open shared object
  17. 实验 详解K8S多节点部署群集
  18. protel99常用元件的电气图形符号和封装形式(二)
  19. Android5g手机,【手机篇】5G手机推荐
  20. JAVA-extends

热门文章

  1. (chap 3 Http报文内的http信息) 编码提升传输速率(2)
  2. 以太坊节点布置(3) 启动geth客户端
  3. 数学建模——一维、二维插值模型详解Python代码
  4. 【Flask】创建一个蓝图
  5. (38)编写 ShellCode
  6. kali下fcrackzip使用
  7. 4.WaitForSingleObject函数分析
  8. 13、 LEFT/RIGHT JOIN:外连接(左连接,右连接)
  9. Python爬取房天下租房信息实战
  10. ACM入门之【前缀和】