<?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"> <!-- MyBatis的全局配置文件 --> <configuration > <!-- 1.配置开发环境 --> <environments default="develop"> <!-- 这里可以配置多个环境,比如develop,test等 --> <environment id="develop"> <!-- 1.1.配置事务管理方式:JDBC:将事务交给JDBC管理(推荐) --> <transactionManager type="JDBC"></transactionManager> <!-- 1.2.配置数据源,即连接池方式:JNDI/POOLED/UNPOOLED --> <dataSource type="POOLED"> <property name="driver" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/yonghedb?characterEncoding=utf-8"/> <property name="username" value="root"/> <property name="password" value="root"/> </dataSource> </environment> </environments> <!-- 2.加载Mapper配置文件,路径以斜杠间隔: xx/xx/../xx.xml --> <mappers> <mapper resource="mybatis/mapper/DoorMapper.xml"/> </mappers> </configuration>