MyBatis 简单使用

作者: 布尔bl | 来源:发表于2019-12-23 16:41 被阅读0次

    0 文件路径图

    image

    1 sql(src\main\mysql\c_customer.sql)

    首先找到 sql 文件

    image

    得到结果

    image

    2 编写 sqlMapConfig.xml(src\main\resources\sqlMapConfig.xml)

    这是一个 mybatis 的配置文件,他的作用是连接数据库以及找到相应的 xml 文件

    image

    3 编写实体类(src\main\java\com\buer\domain\Customer.java)

    实体类与数据库字段对应

    image

    4 编写 CustomerMapper (src\main\java\com\buer\dao\CustomerMapper.java)

    image

    5 编写 CustomerMapper.xml (src\main\resources\CustomerMapper.xml)

    image

    6 测试 (src\test\java\com\com.buer\Test.java)

    image

    7 结果

    执行 src\test\java\com\com.buer\Test.java 的测试方法,得到结果

    image

    8 源码

    https://github.com/buerbl/ssm-learn-crm

    相关文章

      网友评论

        本文标题:MyBatis 简单使用

        本文链接:https://www.haomeiwen.com/subject/glttoctx.html