首頁 > 軟體

連線mysql報錯——沒有設定「usessl=false」的問題

2022-08-18 14:03:20

報錯資訊

Wed Mar 13 17:08:37 CST 2019 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.
 
1:admin

解決辦法            

在設定資料庫的URL時,加上usessl=false就可以了。

新增前

新增後

附上Configuration.xml程式碼

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <!-- mybatis別名定義 -->
    <typeAliases> 
        <typeAlias alias="User" type="com.mybatis.test.User"/> 
    </typeAliases> 
 
    <environments default="development">
        <environment id="development">
        <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
            <property name="driver" value="com.mysql.jdbc.Driver"/>
            <property name="url" value="jdbc:mysql://19****:3306/***?useSSL=false" />
            <property name="username" value="***"/>
            <property name="password" value="***"/>
            </dataSource>
        </environment>
    </environments>
    
    <!-- mybatis的mapper檔案,每個xml組態檔對應一個介面 -->
    <mappers>
        <mapper resource="com/mybatis/test/User.xml"/>
    </mappers>
</configuration>

以上為個人經驗,希望能給大家一個參考,也希望大家多多支援it145.com。


IT145.com E-mail:sddin#qq.com