一、Mybatis环境搭建
- 创建一个maven工程
- 导入依赖
mybatis的依赖
数据库连接依赖(这里使用mysql)
可选:单元测试依赖,日志<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <mybatis.version>3.5.3</mybatis.version> <mysql-connector-java.version>8.0.13</mysql-connector-java.version> <log4j.version>1.2.17</log4j.version> <junit.version>4.11</junit.version> </properties> <dependencies> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql-connector-java.version}</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> </dependency> </dependencies>
- 新建 数据库参数文件 db.