SpringBoot【问题 03】BindingException\MalformedInputException\Error querying database(sqlite数据库)

简介: SpringBoot【问题 03】BindingException\MalformedInputException\Error querying database(sqlite数据库)

1.类文件具有错误的版本 61.0, 应为 52.0

# JDK8+SpringBoot3.1.0
java.lang.UnsupportedClassVersionError: 
ch/qos/logback/classic/spi/LogbackServiceProvider
 has been compiled by a more recent version of the Java Runtime (class file version 55.0), 
this version of the Java Runtime only recognizes class file versions up to 52.0  
# JDK8+[SpringBoot3.0.0-SpringBoot3.0.7]
Error:(3, 47) java: 无法访问org.springframework.web.bind.annotation.RequestMapping
  错误的类文件: /E:/maven-file/org/springframework/spring-web/6.0.9/spring-web-6.0.9.jar!/org/springframework/web/bind/annotation/RequestMapping.class
    类文件具有错误的版本 61.0, 应为 52.0
    请删除该文件或确保该文件位于正确的类路径子目录中。
# JDK8+SpringBoot3.0.7 
此时能正常启动项目了【JDK8尚能饭否?】

2.BindingException

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception 
[Request processing failed; 
nested exception is org.apache.ibatis.binding.BindingException:
Invalid bound statement (not found): 
com.example.demo.web.mapper.CustomMapper.test] with root cause

这个异常需要两步才能解决:

【Step.1】pom添加指定项目的资源文件的位置。

<resources>
  <resource>
    <directory>src/main/java</directory>
    <includes>
      <include>**/*.xml</include>
    </includes>
  </resource>
</resources>

【Step.2】配置文件内指定 Mapper XML 文件的位置。

mybatis-plus:
  mapper-locations: classpath*:/com/example/demo/**/mapper/xml/*.xml

IDEA插件推荐【MyBatisX】

Maper接口写好之后,可以使用插件生成对应的mapper.xml文件:

在接口上右键调用:

选择生成路径:

生成结果:

3.MalformedInputException

org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1

这个报错出现的原因是用Spring Initializr生成的配置文件使用的是当前电脑的编码方式GBK,执行时使用的是UTF-8导致的,删除全部中文也能解决问题。需要保留注释信息的话,需要将文件的编码格式调整为UTF-8

4.Error querying database

这里使用的是SQLite数据库,配置信息如下:

spring:
  datasource:
    dynamic:
      datasource:
        master:
          driver-class-name: org.sqlite.JDBC
          url: jdbc:sqlite:demo.sqlite3
          username:
          password:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: student)
### The error may exist in file [E:\demo\target\classes\com\example\demo\web\mapper\xml\CustomMapper.xml]
### The error may involve com.example.demo.web.mapper.CustomMapper.test
### The error occurred while executing a query
### SQL: select id, name, age from student
### Cause: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: student)] with root cause

目录
打赏
0
0
0
0
273
分享
相关文章
SpringBoot入门 - 添加内存数据库H2
SpringBoot入门 - 添加内存数据库H2
148 3
SpringBoot入门 - 添加内存数据库H2
基于SpringBoot+Vue实现的大学生就业服务平台设计与实现(系统源码+文档+数据库+部署等)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
67 6
基于SpringBoot+Vue的班级综合测评管理系统设计与实现(系统源码+文档+数据库+部署等)
✌免费选题、功能需求设计、任务书、开题报告、中期检查、程序功能实现、论文辅导、论文降重、答辩PPT辅导、会议视频一对一讲解代码等✌
40 4
基于SpringBoot+Vue实现的大学生体质测试管理系统设计与实现(系统源码+文档+数据库+部署)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
38 2
Java后端开发-使用springboot进行Mybatis连接数据库步骤
本文介绍了使用Java和IDEA进行数据库操作的详细步骤,涵盖从数据库准备到测试类编写及运行的全过程。主要内容包括: 1. **数据库准备**:创建数据库和表。 2. **查询数据库**:验证数据库是否可用。 3. **IDEA代码配置**:构建实体类并配置数据库连接。 4. **测试类编写**:编写并运行测试类以确保一切正常。
55 2
基于SpringBoot+Vue实现的冬奥会科普平台设计与实现(系统源码+文档+数据库+部署)
面向大学生毕业选题、开题、任务书、程序设计开发、论文辅导提供一站式服务。主要服务:程序设计开发、代码修改、成品部署、支持定制、论文辅导,助力毕设!
45 0
Python处理数据库:MySQL与SQLite详解 | python小知识
本文详细介绍了如何使用Python操作MySQL和SQLite数据库,包括安装必要的库、连接数据库、执行增删改查等基本操作,适合初学者快速上手。
384 15
使用 Spring Boot 执行数据库操作:全面指南
使用 Spring Boot 执行数据库操作:全面指南
312 1
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database (
117 2
19c 开启Oracle Database Vault
19c 开启Oracle Database Vault
187 1
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等