具体代码
<?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> <typeAliases> <package name="com.itheima.pojo"/> </typeAliases> <!--environments 配置数据库连接环境。 可以配置多个environment,通过default属性来切换不同的environment--> <environments default="development"> <environment id="development"> <transactionManager type="JDBC"/> <dataSource type="POOLED"> <!--数据库连接信息--> <property name="driver" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql:///mybatis?useSSL=false"/> <property name="username" value="root"/> <property name="password" value="123456"/> </dataSource> </environment> </environments> <mappers> <!--加载sql的映射文件--> <!-- <mapper resource="com/itheima/mapper/BrandMapper.xml"/>--> <!--Mapper代理方式--> <package name="com.itheima.mapper"/> </mappers> </configuration>
<environments>标签 配置数据库连接环境 在其中填入具体的数据库信息
<mappers>标签 用来加载sql的映射文件
<typeAliase>标签 填入数据类的地址,用来统一数据类和数据库的名称
- mybatis-config mybatis config xmlmybatis-config mybatis config xml mybatis-config mybatis-config顺序mybatis文件 mybatis-config模板mybatis config 插件mybatis mybatis-config方式 sqlsessionfactoryutils mybatis-config javaweb xml mybatiss-config properties springmvc mybatis-xml mybatis文件xml mybatis-xml mybatis文件xml