environments标签
<?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>
<environments default="development">
<!-- environments: 环境标签, mybatis可以配置多种环境,default指定使用某种环境,可以达到快速切换环境的效果
environment:1).配置一个具体的环境信息,必须有两个标签(transactionManager,dataSource);
2)id属性代表当前环境的唯一标识
transactionManager: 事物管理器
dataSource: 数据源
-->
<environment id="test">
<transactionManager type=""></transactionManager>
<dataSource type=""></dataSource>
</environment>
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property
name="driver"
value="oracle.jdbc.OracleDriver" />
<property
name="url"
value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property
name="username"
value="scott" />
<property
name="password"
value="123456" />
</dataSource>
</environment>
</environments>
<!-- 把sql映射文件(EmployeeMapper.xml)一定要注册到全局配置文件(mybatis-config.xml)中 -->
<mappers>
<mapper resource="EmployeeMapper.xml" />
</mappers>
</configuration>
databaseIdProvider :多数据厂商的支持
<databaseIdProvider type="DB_VENDOR">
<!-- 为不同数据库厂商起别名 -->
<property name="Mysql" value="mysql"/>
<property name="Oracle" value="oracle"/>
</databaseIdProvider>
![](https://i-blog.csdnimg.cn/blog_migrate/ffce413788de29a3caa064845bacd128.png)