Mybatis 报错java.sql.SQLException: No suitable driver found for http://www.example.com

运行项目报错

Error querying database. Cause: java.sql.SQLException: No suitable driver found for http://www.example.com

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLException: No suitable driver found for http://www.example.com
### The error may exist in com/pro/dao/UserMapper.xml
### The error may involve com.pro.dao.UserMapper.getUserList
### The error occurred while executing a query
### Cause: java.sql.SQLException: No suitable driver found for http://www.example.com

我的 properties 配置文件是这样的

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8
username=root
password=123456
<configuration>
    <properties resource="db.properties"/>

    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="${driver}"/>
                <property name="url" value="${url}"/>
                <property name="username" value="${username}"/>
                <property name="password" value="${password}"/>
            dataSource>
        environment>
    environments>
configuration>

我查看了一下编译后的文件,发现我的 mybatis-config.xml 文件中的 ${url} 被编译成了 http://www.example.com

Mybatis 报错java.sql.SQLException: No suitable driver found for http://www.example.com_第1张图片

url 这个变量被覆盖了,直接把 url 改成 jdbcUrl,运行项目问题解决



<configuration>
    <properties resource="db.properties"/>

    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="${driver}"/>
                <property name="url" value="${jdbcUrl}"/>
                <property name="username" value="${username}"/>
                <property name="password" value="${password}"/>
            dataSource>
        environment>
    environments>
configuration>

你可能感兴趣的:(Java,mybatis)