连接数据库SSL警告: Establishing SSL connection without server’s identity verification is not recommended.

Dbutils连接数据库警告

Thu Apr 30 12:05:05 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.

【错误原因】:

请注意:不建议在没有服务器身份验证的情况下建立SSL连接。如果不设置显式选项,则必须建立默认的SSL连接。您需要通过设置useSSL=false显式地禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储


初步解决:

jdbc:mysql://localhost:3306/db_test?useUnicode=true&characterEncoding=utf-8&useSSL=false

更改之后又出现新的问题:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 28 in XML document from class path resource [bean.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 28; columnNumber: 110; 对实体 “characterEncoding” 的引用必须以 ‘;’ 分隔符结尾。

原因就是:在XML中,要显示&这个字符,必须对其转义

如果是XML配置数据源才转义,注解配置无需转义!

改为&转义即可

jdbc:mysql://localhost:3306/db_test?characterEncoding=utf-8&useSSL=false

连接数据库SSL警告: Establishing SSL connection without server’s identity verification is not recommended._第1张图片

你可能感兴趣的:(踩坑记录,连接数据库SSL警告)