当前位置:   article > 正文

001【Bug】记录-SpringBoot3.1搭建问题

001【Bug】记录-SpringBoot3.1搭建问题

001【Bug】记录-SpringBoot3.1搭建问题

本系列文章记录日常开发遇到的Bug,为类似问题的解决提供一点案例或思路



问题描述

面对spring3.1版本的上线,需要去探索一下,这是有必要的,不管怎样终有一天是要升级的嘛!当然可想而知一大堆错误不可避免。

  • 这里有和之前版本类似的错误,
  • 也有和之前版本不一样的错误,
  • 有yml 文件配置的错误
  • 更多的是springboot版本引发其他maven包版本的错误

但是目前来看,就建立起完善的项目来说,都是已经可以解决的错误了。下面针对几个问题简要记录一下

1 springboot3.1 启动报错

问题1 Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

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.
  • 1

这个更Idea 项目设置有关,问题不大,暂时不用管

问题2 ‘java.lang‘ is declared in module ‘java.base‘, which is not in the module graph

问题2 java: 找不到符号 符号: 方法 getMaxId() 位置: 类型为com.easy.id.entity.Segment的变量 segment

Package ‘java.lang‘ is declared in module ‘java.base‘, which is not in the module graph
  • 1

以上两个问题其实是伴生的
这个跟 Java版本 有关,就是使用高版本的Java 如Java 17+时,模块依赖优点变更,这个通过快捷键代码提示 加编译参数即可

问题3 Failed to load driver class com.mysql.cj.jdbc.Driver from HikariConfig class

com.zaxxer.hikari.HikariConfig : Failed to load driver class com.mysql.cj.jdbc.Driver from HikariConfig class classloader jdk.internal.loader.ClassLoaders$AppClassLoader@63947c6b
  • 1

这个跟 pom.xml 有关,把connecter-java-mysql 的版本 改成和您使用的 mysql数据库的版本相对应,笔者是需要升级到 8.0

问题4 configuration’ and ‘configLocation’ can not specified with together

configuration' and 'configLocation' can not specified with together 
  • 1

这个跟 application.yml 文件对于 mybatis 的配置有关 简单来说就如 报错提示所说。解决办法,就是把 mybatis.configuration 的配置 通过新建 mybatisConfig.xml 转移出来(类似于SSM 项目配置 dao-config.xml),在通过 config-location指向这个配置文件的 项目文件夹所在位置。博客园里有篇文章看看就能改了。

IllegalStateException: Property ‘configuration’ and ‘configLocation’ can not specified with together - 梅子猪 - 博客园 (cnblogs.com)

问题5 Factory method ‘sqlSessionFactory’ threw exception with message: Failed to parse mapping resource: 'file

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]'
  • 1

这个最狠,除了面的关键信息,下边报错一大堆,指向提示乱七八糟,看不出什么玩意,很容易说成版本升级导致错误,安慰一下不升级了就完事了。
实际上 跟 application.yml 配置文件 有关,问题还是处在 mybatis 的配置上,笔者没有把 com/cloud/Exam 即项目的主包名添加完全正确导致错误。

mybaits:
	mapperLocations: classpath:com/cloud/Exam/mapper/*.xml
  • 1
  • 2

1.2 application.yml

# 服务端口
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 服
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/480552
推荐阅读
相关标签
  

闽ICP备14008679号