Mybatis常用配置文件

Mapper.xml 、 sqlMapConfig.xml 约束头信息。

 



<?
xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

sqlMapConfig.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"/> <!-- 配置别名 --> <typeAliases> <typeAlias type="com.xxx.pojo.User" alias="User"></typeAlias> </typeAliases> <environments default="dev"> <environment id="dev"> <transactionManager type="JDBC"></transactionManager> <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> <mapper resource="mappers/UserMapper.xml"/> </mappers> </configuration>

 

db.properties.xml 配置信息

jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/userdb jdbc.username=root jdbc.password=root

 

posted @ 2019-08-27 15:27  Courage.Kiven  阅读(205)  评论(0编辑  收藏  举报