SQl语句中起别名和实体类的属性对应即可
select last_name lastName age age from a_admin
Mybatis中开启驼峰命名,需要在Mybatis的配置文件中开启
<settings> <setting name="mapUnderscoreToCamelCase" value="true"/> </settings>
<resultMap id="BaseResultMap" type="com.sli.crowd.entity.Admin"> <id column="id" property="id" jdbcType="INTEGER" /> <result column="login_acct" property="loginAcct" jdbcType="VARCHAR" /> <result column="user_pswd" property="userPswd" jdbcType="CHAR" /> <result column="user_name" property="userName" jdbcType="VARCHAR" /> <result column="email" property="email" jdbcType="VARCHAR" /> <result column="create_time" property="createTime" jdbcType="CHAR" /> </resultMap>