• mybatis一些记录


    1,mybatis中#{sx}会使用?进行替代 ,$(xx)会完整将字符串完成替代

    2,mybaits,表中字段为user_id 在Address.class中没有userId属性,有对象User user。使用#{user.id}来表示。

    3,当数据库中的字段信息和对象属性不一致时,需要通过resultMap来映射。

    <resultMap type="Address" id="addressMap">
    <id column="id" property="id"/>
    <result column="post_code" property="postcode"/>
    </resultMap>

    4, 当数据库中的字段信息和对象的属性不一致时需要通过resultMap来映射

    <resultMap type="Address" id="addressMap">
        <result column="post_code" property="postcode"/>
    </resultMap>

     5,NoClassDefFoundError异常

    java.lang.NoClassDefFoundError: Could not initialize class tk.dongyeblog.shop.util.MyBatisUtil
    at tk.dongyeblog.shop.dao.BaseDao.load(BaseDao.java:64)
    at tk.dongyeblog.shop.dao.BaseDao.load(BaseDao.java:55)
    at tk.dongyeblog.shop.dao.AddressDao.load(AddressDao.java:36)
    at tk.dongyeblog.shop.test.TestAddressDao.testLoad(TestAddressDao.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

     <insert id="add" parameterType="Address">

    错误找了半天,原来是Address写成Adderss了。一定要小心啊!

    如果类确实存在的话,应仔细检查配置文件。一般是类名字写错了。

  • 相关阅读:
    《代码整洁之道》阅读笔记(三)
    pyqt5知识
    软件开发的生命周期
    软件过程与管理CMMI
    pyQt5练习(三)
    pyQt5练习(二)
    《代码整洁之道》阅读笔记(二)
    pyQt5练习(一)
    Android Studio错误:Connect to 127.0.0.1:1080 [/127.0.0.1] failed: Connection refused: connect
    AndroidStudio:Minimum supported Gradle version is XXX Current version is XXX
  • 原文地址:https://www.cnblogs.com/dongye/p/3298026.html
Copyright © 2020-2023  润新知