赞
踩
本系列文章记录日常开发遇到的Bug,为类似问题的解决提供一点案例或思路
面对spring3.1版本的上线,需要去探索一下,这是有必要的,不管怎样终有一天是要升级的嘛!当然可想而知一大堆错误不可避免。
但是目前来看,就建立起完善的项目来说,都是已经可以解决的错误了。下面针对几个问题简要记录一下
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
这个更Idea 项目设置有关,问题不大,暂时不用管
Package ‘java.lang‘ is declared in module ‘java.base‘, which is not in the module graph
以上两个问题其实是伴生的
这个跟 Java版本 有关,就是使用高版本的Java 如Java 17+时,模块依赖优点变更,这个通过快捷键代码提示 加编译参数即可
com.zaxxer.hikari.HikariConfig : Failed to load driver class com.mysql.cj.jdbc.Driver from HikariConfig class classloader jdk.internal.loader.ClassLoaders$AppClassLoader@63947c6b
这个跟 pom.xml 有关,把connecter-java-mysql 的版本 改成和您使用的 mysql数据库的版本相对应,笔者是需要升级到 8.0
configuration' and 'configLocation' can not specified with together
这个跟 application.yml 文件对于 mybatis 的配置有关 简单来说就如 报错提示所说。解决办法,就是把 mybatis.configuration 的配置 通过新建 mybatisConfig.xml 转移出来(类似于SSM 项目配置 dao-config.xml),在通过 config-location指向这个配置文件的 项目文件夹所在位置。博客园里有篇文章看看就能改了。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception with message: Failed to parse mapping resource: 'file [D:\CodePractice\Backend\Java\JavaBigData\knowleadge\Part06\springbootv3.1\target\classes\mapper\SchoolstudentMapper.xml]'
这个最狠,除了面的关键信息,下边报错一大堆,指向提示乱七八糟,看不出什么玩意,很容易说成版本升级导致错误,安慰一下不升级了就完事了。
实际上 跟 application.yml 配置文件 有关,问题还是处在 mybatis 的配置上,笔者没有把 com/cloud/Exam 即项目的主包名添加完全正确导致错误。
mybaits:
mapperLocations: classpath:com/cloud/Exam/mapper/*.xml
# 服务端口 server: port: 8082 # 数据库连接串 spring: application: name: springboot3.1 thymeleaf: cache: false # 禁用 thymeleaf 缓存 datasource: url: jdbc:mysql://localhost:3306/dbschoolexam?zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: 123456 servlet: multipart: # 是否支持批量上传 (默认值 true) enabled: true # 上传文件的临时目录 (一般情况下不用特意修改) location: # 上传文件最大为 1M (默认值 1M 根据自身业务自行控制即可) max-file-size: 1048576 # 上传请求最大为 10M(默认值10M 根据自身业务自行控制即可) max-request-size: 10485760 # 文件大小阈值,当大于这个阈值时将写入到磁盘,否则存在内存中, # (默认值0 一般情况下不用特意修改) file-size-threshold: 0 # 判断是否要延迟解析文件(相当于懒加载,一般情况下不用特意修改) resolve-lazily: false data: redis: lettuce: pool: max-active: 8 # 连接池最⼤连接数(使⽤负值表示没有限制) 默认 8 max-wait: -1 # 连接池最⼤阻塞等待时间(使⽤负值表示没有限制) 默认 -1 max-idle: 8 # 连接池中的最⼤空闲连接 默认 8 min-idle: 0 # 连接池中的最⼩空闲连接 默认 0 database: 0 # Redis 数据库索引(默认为 0) host: 192.168.80.20 # Redis 服务器地址 port: 6379 # Redis 服
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。