Springboot mybatis逆向工程org.springframework.beans.factory.BeanCreationException: Error creating bean错误
前言
声明:这个错误只是作者在学习时候的一种情况,并不一定能够解决所有情况。还望各位审视出错具体环境!谢谢。
今天使用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
。。。
- 首先有一个其他原因就是版本不一致:mysql的jar包版本和mysql版本要一致。用的jar包不同出来的东西不同也会出错(亲测)
- 其次逆向每次生成要把上一次剩余的删除干净再生成,我每次剩部分就会报错
- 我出现这个问题的主要原因是注入失败,失败的原因是mapper.java和mapper.xml不一致,确切的来说是我没配置好使得mapper.xml多了mapper.java没有的内容。思路如下:
首先一点是mybatis逆向工程生成的Mapper.java要加@Mapper注解才行,但是加了注解还是会报类似的错,那么我根据我的节奏剖析原因。
- 我想使用逆向工程生成一些代码普通最后一项配置是这样的
<table tableName="campus" domainObjectName="campus"></table>
- 但是逆向工程生成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错误相关推荐
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManage
1.错误原因(异常描述) org.springframework.beans.factory.BeanCreationException: Error creating bean with name ...
- 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 ...
- Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name
spring boot 启动报错 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating ...
- 使用JPA进行update操作时,报org.springframework.beans.factory.BeanCreationException: Error creating bean with
使用JPA进行update操作时,报org.springframework.beans.factory.BeanCreationException: Error creating bean with ...
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 't
1. 今天在做redis的时候,爆出这样的错误: Caused by: org.springframework.beans.factory.BeanCreationException: Error ...
- 【终极办法】org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘helloC
报错信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloC ...
- “org.springframework.beans.factory.BeanCreationException: Error creating bean with name xxx“问题解决
问题描述 在本地跑项目的时候出现报错信息: org.springframework.beans.factory.BeanCreationException: Error creating bean w ...
- springboot启动报org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean..
这是一个非常常见一个没有注入bean的错误 报错情况如下 org.springframework.beans.factory.UnsatisfiedDependencyException: Error ...
最新文章
- ProcessDialogKey 方法实现回车自动换行
- 20190318-使用类做一个简单的图书馆管理系统
- [云炬创业基础笔记] 第四章测试5
- OpenGL在frag着色器中模拟手电筒效果
- Java中创建数组的几种方法
- Solaris是出色的Java开发平台的原因
- Ubuntu 下无法Tab键自动补全功能解决办法
- 常见花材的固定的方法有哪些_固定无梁拱形屋顶的方法都有哪些呢?
- C语言练习:第二大整数
- matlab优化工具箱安装,MATLAB优化工具箱 OPTI的安装
- 计算机一级题库百度云0,全国计算机等级考试一级题库完整.pdf
- php相册照片批量修改,php如何实现批量修改文件名称
- 使用流程图描述程序的功能与流程
- 诡异大阳飙升动因何在
- (附源码)计算机毕业设计SSM教师教学质量评价系统
- [bowtie2, libtbb.so.2]error while loading shared libraries: libtbb.so.2: cannot open shared object
- 实验 详解K8S多节点部署群集
- protel99常用元件的电气图形符号和封装形式(二)
- Android5g手机,【手机篇】5G手机推荐
- JAVA-extends