搭建Mybatis环境遇到的问题

1. org.apache.ibatis.binding.BindingException: Type interface com.hsz.dao.UserDao is not known to the MapperRegistry.

解决方法:

<!--每一个Mapper.xml都需要在mybatis核心配置文件中注册-->
<mappers>
    <mapper resource="com/hsz/dao/UserMapper.xml"/>
</mappers>


2. java.lang.ExceptionInInitializerError

解决方法:

<!--在pom.xml中的project标签中配置build,来防止我们资源导出失败的问题-->
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>**/*.properties</exclude>
                <exclude>**/*.xml</exclude>
            </excludes>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
            </includes>
            <filtering>false</filtering>
        </resource>
    </resources>
</build>

3. java.io.IOException: Could not find resource mybatis-config.xml

解决方法:
将放置mybatis-config.xml的文件夹与src放在同一目录下


4.Caused by: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone.

解决方法:

时差问题:在URL后面加上serverTimezone=GMT%2B8

如:"jdbc:mysql://localhost:3306/mybatis?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=GMT%2B8"

5. Caused by: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust

解决方法:

原因是因为使用了useSSL=true,只需要改为useSSL=false就可以解决了
posted @ 2020-10-08 14:18  han_sh_zh  阅读(177)  评论(0编辑  收藏  举报