背景:
在使用SpringBoot1.x版本的时候出现Mysql出现异常,出现SSL没有得到服务的连接认证。(在SpringBoot2.x版本中暂时没有发现该问题)
[code]2020-07-22 14:35:10.711 INFO 18480 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet \'dispatcherServlet\': initialization completed in 54 ms要查询的用户Id为:2Wed Jul 22 14:35:10 CST 2020 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.Wed Jul 22 14:35:11 CST 2020 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
解决方案:
步骤:
1. 首先就是Mysql的数据库配置:
之前使用:地址+端口号+数据库的名称
[code]spring:datasource:url: jdbc:mysql://192.168.59.129:3306/Jpausername: rootpassword: 123456driver-class-name: com.mysql.jdbc.Driver
这种情况在每次使用数据库都会有异常警告,所以我们进行配置如下:
[code]spring:datasource:url: jdbc:mysql://192.168.59.129:3306/Jpa?useUnicode=true&characterEncoding=utf-8&useSSL=falseusername: rootpassword: 123456driver-class-name: com.mysql.jdbc.Driver
加上上面的配置就可以正常使用了。