Spring整合mybatis

    xiaoxiao2021-11-29  20

    导入jar

    导入spring的配置文件已经Mybatis的配置文件

    还需要导入mysql的jar

    编写配置文件

    mybatis的配置文件:mybatis.cfg.xml

    因为用spring的IOC容器来空值SqlSessionFactory

    demo的项目结构

    UserDao:

    UserDaoImpl:

    User和User.mapper.xml

    实现

    在映射文件中的namespace和接口对应这里没有写!

    UserDao的接口中的方法和select的id对应

    在main方法中测试:

    转载请注明原文地址: https://ju.6miu.com/read-678829.html

    最新回复(0)