1.在Mybatis的pom.xml文件中添加依赖
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.11</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.17</version> </dependency>
2.全局配置文件(mybatis-config.xml)(src/main/resources)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 环境,可以配置多个,default:指定采用哪个环境 -->
<environments default="dev">
<!-- id:唯一标识 -->
<environment id="dev">
<!--采用JDBC进行事务的管理commit/rollback-->
<transactionManager type="JDBC"/>
<!-- 数据源,连接池类型的数据源 -->
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/babytun?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC"/>
<property name="username" value="root"/>
<property name="password" value="197366"/>
</dataSource>
</environment>
</environments>
</configuration>
标签:xml,入门,amp,mybatis,007,mysql,Mybatis,org From: https://www.cnblogs.com/LLL0617/p/16846461.html