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学习疑问
    HTTP method GET is not supported by this URL
    详解ListView分页(带图片)显示用法案例
    MySQL 字段数据类型/长度
    getRequestDispatcher()与sendRedirect()的区别
    Codeforces Round #754 (Div. 2) D,E 题解
    CCPC2019 Harbin Site B.Binary Numbers
    2020 EC Final D. City Brain
    [USACO15JAN]Grass Cownoisseur G
    CF1295F Good Contest
  • 原文地址:https://www.cnblogs.com/like3ong/p/13237010.html
Copyright © 2011-2022 走看看