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

目录
相关文章
|
1月前
|
API 数据库 C语言
【C/C++ 数据库 sqlite3】SQLite C语言API返回值深入解析
【C/C++ 数据库 sqlite3】SQLite C语言API返回值深入解析
170 0
|
1月前
|
NoSQL Java 数据库
【问题篇】springboot项目通过数据库限制实例端口号
【问题篇】springboot项目通过数据库限制实例端口号
19 0
|
14天前
|
SQL 关系型数据库 数据库
Python中SQLite数据库操作详解:利用sqlite3模块
【4月更文挑战第13天】在Python编程中,SQLite数据库是一个轻量级的关系型数据库管理系统,它包含在一个单一的文件内,不需要一个单独的服务器进程或操作系统级别的配置。由于其简单易用和高效性,SQLite经常作为应用程序的本地数据库解决方案。Python的内置sqlite3模块提供了与SQLite数据库交互的接口,使得在Python中操作SQLite数据库变得非常容易。
|
18天前
|
存储 关系型数据库 MySQL
【mybatis-plus】Springboot+AOP+自定义注解实现多数据源操作(数据源信息存在数据库)
【mybatis-plus】Springboot+AOP+自定义注解实现多数据源操作(数据源信息存在数据库)
|
19天前
|
关系型数据库 MySQL 数据库连接
Python+SQLite数据库实现服务端高并发写入
Python中使用SQLite内存模式实现高并发写入:创建内存数据库连接,建立表格,通过多线程并发写入数据。虽然能避免数据竞争,但由于SQLite内存模式采用锁机制,可能在高并发时引发性能瓶颈。若需更高性能,可选择MySQL或PostgreSQL。
23 0
|
19天前
|
Java 测试技术 数据库
SpringBoot启动时设置不加载数据库
SpringBoot启动时设置不加载数据库
10 0
|
19天前
|
SQL Java 调度
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
|
1月前
|
SQL Java 数据库连接
springboot解析txt文件顺便加到数据库中(nohup文件)
springboot解析txt文件顺便加到数据库中(nohup文件)
112 1
|
1月前
|
关系型数据库 数据库 C++
嵌入式数据库sqlite3【基础篇】基本命令操作,小白一看就懂(C/C++)
嵌入式数据库sqlite3【基础篇】基本命令操作,小白一看就懂(C/C++)