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