zoukankan      html  css  js  c++  java
  • Mybatis 报错

    Mybatis 报错

    builder.BuilderException: Error parsing SQL Mapper Configuration

    Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/xxx/dao/UserDao.xml
    

    image-20200704162223175

    这个原因是我的 resources 文件下面的 package 不能建立,因此我将其标记为 test resources,问题解决

    image-20200704222258355

    It's likely that neither a Result Type nor a Result Map was specified

    这个原因是:Mybatis配置文件中没有返回类型参数

    Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException 是文件查询之后不知道将结果集封装到哪里

    image-20200704162325182

    因此在查询的方法id后面添加一个resultType,

    image-20200704212854636

    将结果封装至User

    image-20200704213215783

    InvalidConnectionAttributeException

    还有一个关于时区的问题,此问题为时区问题,在 JDBC 的连接 url 部分加上 serverTimezone=UTC 即可。
    如果选择utc会比中国时间早8个小时,如果在中国,可以选择Asia/Shanghai或者Asia/Hongkong

    UTC 即 Universal Time Coordinated 世界标准时间

    Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    

    解决方法:

    <property name="url" value="jdbc:mysql://localhost:3306/dbMybatis?serverTimezone=UTC"/>
    
  • 相关阅读:
    Java设计模式之代理模式
    Java设计模式之单例模式
    Android 退出多Activity的application的方式
    自己动手系列——实现一个简单的LinkedList
    自己动手系列——实现一个简单的ArrayList
    Java多线程基础——Lock类
    制作一个功能丰富的Android天气App
    IdentityServer4 学习二
    IdentityServer4 学习一
    SC创建服务编写bat脚本
  • 原文地址:https://www.cnblogs.com/like3ong/p/13237010.html
Copyright © 2011-2022 走看看