Skip to content

Instantly share code, notes, and snippets.

@cheng470
Created February 7, 2015 08:29
Show Gist options
  • Save cheng470/22927b37ec80568a5eb0 to your computer and use it in GitHub Desktop.
Save cheng470/22927b37ec80568a5eb0 to your computer and use it in GitHub Desktop.
Mybatis 第一个例子优化,优化配置文件
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/test
username=root
password=123456
<?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="config.properties"></properties>
<!-- 配置别名 -->
<typeAliases>
<typeAlias type="com.test.bean.User" alias="User"/>
</typeAliases>
<!-- 配置环境 -->
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<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="userMapper.xml"/>
</mappers>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment