话不多说,直接贴代码
<?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> <!--引入数据库连接文件--> <properties resource="dbMybatis.properties"></properties> <!--mybatis的全局设置--> <settings> <setting name="mapUnderscoreToCamelCase" value="true"/> </settings> <!--环境配置,默认为development,可以进行多个配置,根据default=""进行切换--> <environments default="development"> <!--环境配置 可以创建多个environment 通过设置不同的id可以切换不同的数据库连接--> <environment id="development"> <transactionManager type="JDBC" /> <dataSource type="POOLED"> <property name="driver" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </dataSource> </environment> </environments> <!-- 将我们写好的sql映射文件(EmployeeMapper.xml)一定要注册到全局配置文件(mybatis-config.xml)中 --> <mappers> <mapper resource="EmployeeMapper.xml" /> <mapper resource="com/heima/dao/UserMapper.xml" /> <!-- 使用注解 --> <mapper class="com.heima.dao.UserDao"></mapper> </mappers> </configuration>