SpringBoot整合Mybatis总结

项目整合是参考此blog进行的,使用其中的全注解方式实现的。以下列出整合过程中遇到的几个问题及解决方案:

  • maven依赖

解决方案:参考此blog

其中,此部分概念需要了解一下

传递依赖冲突解决

  • maven的pom文件中parent节点使用properties定义的属性问题

解决方案:参考此blog


  • SpringBoot启动报错

问题1:IllegalStateException和ClassNotFoundException

解决方案:参考此blog

其中,之所以报这个错,是因为SpringBoot整合Mybatis,引入的依赖如下

<dependency>
   <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>1.3.2</version>
</dependency>

SpringBoot版本问题,之前使用的是1.3.3.RELEASE,版本过低,使用以下版本即可解决此报错

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>1.5.12.RELEASE</version>
</parent>

但是,还有一个坑。那就是了解到是版本过低问题之后,首先想到使用最高版本 2.0.0.RELEASE,但是会报下面这个错

问题2:NoSuchMethodError

解决方案:之所以有这个报错,就是因为使用了SpringBoot高版本2.0.0.RELEASE,将版本改回1.5.12.RELEASE即可解决这个报错,参考此blog

以上,就是SpringBoot启动报错的解决方案,其实还是版本问题。


接下来,就是IDEA的坑了,坑惨了!

  • DataBase

问题:控制台一直有如下报错

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

解决方案:试了很多方法,就是不行,后面在一个blog下,看到了这个评论回复

恍然大悟,虽然在application.yml中配置了datasource,但是看了一眼classes下的application.yml并没有这个配置,才知道是IDEA缓存问题,没有重新编译配置文件,重新编译一下即可。

参考此blog,解决IDEA缓存问题,有的时候还需要手动进行编译文件,然后执行文件同步才能看到编译后的效果,很是坑啊,而且编译进行测试过程中,发现好像java文件中的单纯的空行,在class文件里好像并没体现出来啊,不知道是不是java编译器进行了优化,不影响正常执行。


  • Establishing SSL

问题:项目成功启动,可以正常访问,但是启动后第一次访问,控制台会出现警告

WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

解决方案:参考blog1blog2,url中添加useSSL=true即可解决。

以上所有,就是项目整合过程中遇到的问题,贴出来脱坑!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值