連接mysql報錯——沒有設置“usessl=false”的問題

報錯信息

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>

以上為個人經驗,希望能給大傢一個參考,也希望大傢多多支持WalkonNet。

推薦閱讀: