微信登录

mysql - 编程式 - MyBatis - 加入依赖 - pom.xml

简介

MyBatis是优秀的持久层框架
MyBatis使用XML将SQL与程序解耦,便于维护
MyBatis学习简单,执行高效,是JDBC的延伸

https://mybatis.org/mybatis-3/zh/index.html

引入MyBatis
创建核心配置文件
依赖创建实体(Entity)类
创建Mapper映射文件
初始化SessionFactory
利用SqlSession对象操作数据

1、Maven加入依赖/pom.xml

  1. <dependencies>
  2. <!-- 单元测试 -->
  3. <dependency>
  4. <groupId>junit</groupId>
  5. <artifactId>junit</artifactId>
  6. <version>4.12</version>
  7. <scope>test</scope>
  8. </dependency>
  9. <!-- MyBatis核心依赖 -->
  10. <dependency>
  11. <groupId>org.mybatis</groupId>
  12. <artifactId>mybatis</artifactId>
  13. <version>3.3.1</version>
  14. </dependency>
  15. <!-- MySQL数据库 -->
  16. <dependency>
  17. <groupId>mysql</groupId>
  18. <artifactId>mysql-connector-java</artifactId>
  19. <version>5.1.38</version>
  20. </dependency>
  21. <!-- 日志相关 -->
  22. <dependency>
  23. <groupId>org.slf4j</groupId>
  24. <artifactId>slf4j-api</artifactId>
  25. <version>1.7.12</version>
  26. </dependency>
  27. <dependency>
  28. <groupId>org.slf4j</groupId>
  29. <artifactId>slf4j-log4j12</artifactId>
  30. <version>1.7.12</version>
  31. </dependency>
  32. <dependency>
  33. <groupId>log4j</groupId>
  34. <artifactId>log4j</artifactId>
  35. <version>1.2.17</version>
  36. </dependency>
  37. </dependencies>

mybatis版本 - 官网有最新版本号
https://blog.mybatis.org/

mysql版本 - 可以不写

mysql - 编程式 - MyBatis - 加入依赖 - pom.xml