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