<?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="db.properties"></properties>
<typeAliases>
<typeAlias type="unity.User" alias="User"/>
<typeAlias type="unity.Product" alias="Product"/>
<typeAlias type="unity.LeaveMessage" alias="LeaveMessage"/>
</typeAliases>
<environments default="devlopment">
<environment id="devlopment">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="unity/User.xml"/>
<mapper resource="unity/Product.xml"/>
<mapper resource="unity/LeaveMessage.xml"/>
</mappers>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties resource="db.properties"></properties>
<typeAliases>
<typeAlias type="unity.User" alias="User"/>
<typeAlias type="unity.Product" alias="Product"/>
<typeAlias type="unity.LeaveMessage" alias="LeaveMessage"/>
</typeAliases>
<environments default="devlopment">
<environment id="devlopment">
<transactionManager type="JDBC"></transactionManager>
<dataSource type="POOLED">
<property name="driver" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="unity/User.xml"/>
<mapper resource="unity/Product.xml"/>
<mapper resource="unity/LeaveMessage.xml"/>
</mappers>
</configuration>
2创建db.properties
具体内容如下
driver=com.mysql.jdbc.Driver
username=root
password=123456
url=jdbc:mysql://localhost:3306/yimai?characterEncoding=UTF-8//yimai是数据库名称
拿来复制粘贴即可使用