MyBatis环境搭建和入门案例
1.创建一个Maven项目
2.定义项目名称与存储路径
3.数据库表
(1)account表
(2)role表
(3)user表
(4)user_role表
【下面通过XML方式对MyBatis进行配置,还有一种注解配置方式】
4.在pom.xml文件中导入相关依赖
(1)导入MyBatis依赖
通过访问MyBatis官网(https://mybatis.org/mybatis-3),在(https://mybatis.org/mybatis-3/getting-started.html)找到相关的依赖代码块,粘贴复制到pm.xml文件中。
这里使用3.4.5版本,下载请使用网盘链接:链接:https://pan.baidu.com/s/1nS8nJbDoEV2DzyR3DkpMnQ 提取码:abcd --来自百度网盘超级会员V1的分享
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
(2)导入mysql依赖
<dependency>
<groupId>mysql</groupId>