您的当前位置:首页正文

idea配制mybatis+mysql8.0问题

2024-11-12 来源:个人技术集锦

问题1:Cause: java.io.IOException: Could not find resource com/sz/mapper/GirlMapper.xml

<mappers>
        <mapper resource="com/sz/mapper/GirlMapper.xml"/>
</mappers>

改为

<mappers>
        <mapper resource="com.sz.mapper/GirlMapper.xml"/>
    </mappers>

问题2:连接mysql8.0是要用mysql-connector-java8.0版本的

配制如下

<environments default="dev">
        <environment id="dev">
            <transactionManager type="JDBC"></transactionManager>
            <dataSource type="UNPOOLED">
                <property name="driver" value="com.mysql.cj.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useUnicode=true&amp;characterEncoding=utf8&amp;serverTimezone=GMT"/>
                <property name="username" value="root"/>
                <property name="password" value="root123"/>
            </dataSource>
        </environment>
    </environments>

mysql8.0中有时区的差别,故要添加上serverTimezone=GMT
由于idea将&当做特殊字符,故使用&amp;代替

显示全文