[mybatis]Configuration XML_settings

Posted 唐火

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[mybatis]Configuration XML_settings相关的知识,希望对你有一定的参考价值。

settings

  • settings包含很多重要的设置项
    • setting:用来设置每一个设置项
    • name:设置项名
    • value:设置项取值

mapUnderscoreToCamelCase

  • 开启驼峰命名法
  <settings>
        <setting name="mapUnderscoreToCamelCase" value="true"/>
    </settings>

Employee:

package com.atguigu.mybatis.bean;


public class Employee 

    private Integer id;
    private String lastName;
    private String email;
    private String gender;

   

EmployeeMapper.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">
<mapper namespace="com.atguigu.mybatis.dao.EmployeeMapper">



<select id="getEmpById" resultType="com.atguigu.mybatis.bean.Employee">

    select id,last_name ,email,gender from tb1_employee where id = #id

</select>
</mapper>

bean的lastName可以与数据库的last_name映射上了!

以上是关于[mybatis]Configuration XML_settings的主要内容,如果未能解决你的问题,请参考以下文章

MyBaties--Mapper configuration

mybatis:"configuration" must match "(properties?,settings?,typeAliase.....

MyBatis异常-Property 'configLocation' not specified, using default MyBatis Configuration

mybatis配置文件说明(configuration)

精通Mybatis之Configuration配置体系

精通Mybatis之Configuration配置体系