mybatis-config.xml映射文件
<?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="jdbc.properties"/> <environments default="development"> <environment id="development"> <!-- ACID --> <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> <mappers>
<!-- 映射你的xxxxMapper.xml文件 -->
<mapper resource="com/../*Mapper.xml"/>
</mappers>
</configuration>
jdbc.properties属性文件
jdbc.driver=com.mysql.jdbc.Driver #修改这里的端口号/数据库/ jdbc.url=jdbc:mysql://127.0.0.1:3306/这里是你的数据库名称?useUnicode=true&characterEncoding=UTF-8 jdbc.username=root #修改密码 jdbc.password=root
原文:http://www.cnblogs.com/lusid/p/5513751.html