• 日常报错记录2: MyBatis:DEBUG [main]


     直接上干货:

     报错归纳1:

     DEBUG [main] - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.

    原因:xml里面不能有java方不存在的类,它是会去找的,找不到就报错,所以,万一删掉java类了,xml里面的相对应映射的字段也要注释掉。遇到两次了!浪费不少时间!

    2.MyBatis     他要加空构造   实例化对象

    原因:MyBitis ,他实体类pojo  class里 要加空构造

    3.写法

     class 是点,路径是斜杠

    4.

    xml 控制多级级联查数据库,是可以的,(MyBatis xml作为实现 数据库查询),我这里四级连着查询

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mapper
            PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="com.XXXX.dao.ShopDao">
    
    
    <!--private int sid;
    
        private String sname;
    
        private List<Book> blist;-->
    
    <resultMap id="resultMap_shop" type="shop">
    
        <id property="sid" column="sid"></id>
        <result property="sname" column="sname" ></result>
    
        <collection property="blist"  ofType="book">
            <id property="bid" column="bid"></id>
            <result property="bname" column="bname"></result>
    
                <association property="user" javaType="user">
                    <id property="uid" column="uid"></id>
                    <result property="uname" column="uname"></result>
                    <result property="password" column="password"></result>
    
                    <association property="p" javaType="person" >
                        <id property="pid" column="pid"></id>
                        <result property="pname" column="pname"></result>
                        <result property="sex" column="sex"></result>
                        <result property="birthday" column="birthday"></result>
                    </association>
    
                </association>
    
        </collection>
       <!-- <association property="blist" javaType=""-->
    </resultMap>
    
    <!-- List<Shop> getAll(int sid);-->
    
        <select id="getAll" parameterType="int" resultMap="resultMap_shop">
          select from t_shop s,t_book b,t_user u,t_person p where u.user_person_fk=p.pid and b.book_user_fk=u.uid and s.sid=#{sid}
    
        </select>
    
    
    
    
    </mapper>

    5.

    Cause: java.lang.NoSuchMethodException: com.offcn.dao.ShopDao.<init>(),其实是缺少构造,但构造没问题,之后发现是这个写错

  • 相关阅读:
    linux shell 获取文件夹全文绝对路径
    Selenium自动化获取WebSocket信息
    Automatically generating nice graphs at end of your Load Test with Apache JMeter and JMeter-Plugins
    卡夫卡与风暴:卡夫卡和风暴的明智比较
    Apache Kafka安全| Kafka的需求和组成部分
    Kafka Schema Registry | 学习Avro Schema
    QT 内部使用函数列表
    QT图标添加
    QT快捷键
    QT软件上架以及自启动
  • 原文地址:https://www.cnblogs.com/shiyuzhahan/p/10534490.html
Copyright © 2020-2023  润新知