实体类
public class UserInfoVo { @Schema(description = "登录帐号") private String uAccount; @Schema(description = "用户姓名") private String uName; @Schema(description = "手机号") private String uTel; @Schema(description = "电子邮箱") private String uEmail; @Schema(description = "头像") private String uAvatar; @Schema(description = "附加说明") private String uSubject; }
mapper
@Select(" select u_account,u_name,u_tel,u_email,u_avatar,u_subject " + " from sys_users " + " where aid=#{uId} " + " limit 1 ") public UserInfoVo getInfoById(int uId);
返回前端,全部小写,并没有驼峰,甚至在 mapper 里面写 select u_account as uAccount 一样是小写
试了一下别名,发现问题解决了!
public class UserInfoVo { @Schema(description = "登录帐号") private String urAccount; @Schema(description = "用户姓名") private String urName; @Schema(description = "手机号") private String urTel; @Schema(description = "电子邮箱") private String urEmail; @Schema(description = "头像") private String urAvatar; @Schema(description = "附加说明") private String urSubject; }
@Select(" select u_account as ur_account,u_name as ur_name,u_tel as ur_tel,u_email as ur_email,u_avatar as ur_avatar,u_subject as ur_subject " + " from sys_users " + " where aid=#{uId} " + " limit 1 ") public UserInfoVo getInfoById(int uId);
找不到问题,java 新手不知道原因何在,记录一下吧:数据库字段名下划线前只有一个字符的时候不会自动转驼峰,只会转成全部小写格式,如 u_account 转成 uaccount,可以使用别名 ur_account 可得到 urAccount
标签:account,description,驼峰,spring,boot,private,ur,String,Schema From: https://www.cnblogs.com/laoq112/p/18394222