当前位置: 首页 > news >正文

Springboot+mybaits-plus+h2集成产生的一些问题(not found tables)

一、问题描述

org.h2.jdbc.JdbcSQLSyntaxErrorException:  Table "EP_MAPPING" not found (this database is empty);

大概就是说在引入mybatis-plus的依赖后,找不到数据库找不到表的问题。
排查方向:在引入mybatis+h2时,是可以正常运行的,但是改为mybtis-plus后,报错找不到tables。按理说,mybatis-plus集成了mybatis,一般不会出现这样的问题。
排查结果:版本问题,不兼容。
springboot 2.7.x
mybatis-plus 3.5.3.2
h2内嵌在springboot parent里边

<?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 https://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.7.14</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>cn.isungent.ird</groupId><artifactId>epdx</artifactId><version>0.0.1-SNAPSHOT</version><name>epdx</name><description>Enterprise Data Platform</description><properties><java.version>1.8</java.version><mybatis-plus.version>3.5.3.2</mybatis-plus.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><!-- NOTE: cannot exclude jackson because swagger needs it. --></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.3.1</version></dependency><dependency><groupId>com.h2database</groupId><artifactId>h2</artifactId><scope>runtime</scope></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter-test</artifactId><version>${mybatis-plus.version}</version><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/com.google.code.gson/gson --><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.10.1</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.12.0</version></dependency><!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --><dependency><groupId>org.mockito</groupId><artifactId>mockito-core</artifactId><version>4.11.0</version><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>3.0.0</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-boot-starter</artifactId><version>3.0.0</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>3.0.0</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>${mybatis-plus.version}</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-extension</artifactId><version>${mybatis-plus.version}</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>
</project>

yml配置

spring:datasource:driverClassName: org.h2.Driverurl: jdbc:h2:mem:test-dbsql:init:data-locations: classpath:db/data.sqlencoding: utf8schema-locations: classpath:db/schema.sqlh2:console:enabled: truepath: /h2-console
http://www.lryc.cn/news/135013.html

相关文章:

  • 【C#学习笔记】C#特性的继承,封装,多态
  • 常用的电参数
  • Rabbitmq的应用场景
  • 【CSS动画08--流光按钮】
  • 计算机视觉:比SAM快50倍的分割一切视觉模型FastSAM
  • 【官方中文文档】Mybatis-Spring #目录
  • ardupilot开发 --- Lua脚本篇
  • python35种绘图函数总结,3D、统计、流场,实用性拉满
  • shell脚本语句(画矩形、三角形、乘法表和小游戏)(#^.^#)
  • vue3、react组件数据传值对比分析——父组件传递子组件,子组件传递父组件
  • 2023国赛数学建模C题思路模型代码 高教社杯
  • wxPython使用matplotlib绘制动态曲线
  • JVM——类的生命周期
  • 【Docker】docker数据卷(数据挂载)持久化
  • Spring Boot实现IP地址解析
  • 小程序中通过canvas生成并保存图片
  • Error creating bean with name ‘esUtils‘ defined in file
  • Java开发面试题 | 2023
  • Java课题笔记~ 自定义拦截器实现权限验证
  • 微信小程序使用npm引入三方包详解
  • pytest自动化框架运行全局配置文件pytest.ini
  • 视频播放实现示例Demo
  • makefile的自动化变量
  • 使用Kind搭建本地k8s集群环境
  • 【STM32RT-Thread零基础入门】 7. 线程创建应用(多线程运行机制)
  • .net日志系统
  • SpringCloud学习笔记(二)_Eureka注册中心
  • spark的eventLog日志分析
  • 探究Java spring中jdk代理和cglib代理!
  • 反转链表(C++)