结构
第三方属性文件
db.properties
# mysql \u5F00\u53D1\u73AF\u5883
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/1227?characterEncoding=utf-8
username=root
password=1999
# mysql \u6D4B\u8BD5\u73AF\u5883
# driver=com.mysql.jdbc.Driver
# url=jdbc:mysql://192.168.0.131:3306/1227?characterEncoding=utf-8
# username=root
# password=1999
# mysql \u751F\u4EA7\u73AF\u5883
# driver=com.mysql.jdbc.Driver
# url=jdbc:mysql://192.168.0.131:3306/1227?characterEncoding=utf-8
# username=root
# password=1999
全局配置文件
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="db.properties"></properties>
<typeAliases>
<!-- 取别名 不区分大小写 -->
<!-- <typeAlias type="com.sxt.pojo.User" alias="user"/> -->
<!-- 指定类型名称的所属package -->
<package name="com.sxt.pojo"/>
</typeAliases>
<typeHandlers>
<!-- 绑定自定义的类型处理器 -->
<typeHandler handler="com.sxt.typehandler.MyTypeHandler"/>
</typeHandlers>
<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=