springboot获取数据库数据报错
User.java代码
package com.example.demo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import javax.annotation.Resource;
@Resource
@TableName("user")
public class User {
@TableId(type = IdType.AUTO)
public Integer userId;
public String userName;
public Integer userSex;
public Integer getUserId() { return userId; }
public void setUserId(Integer user_Id) {
this.userId = user_Id;
}
public String getUserName() {
return userName;
}
public void setUserName(String user_Name) {
this.userName = user_Name;
}
public Integer getUserSex() {
return userSex;
}
public void setUserSex(Integer user_Sex) {
this.userSex = user_Sex;
}
@Override
public String toString() {
return "User{" +
"userId=" + userId +
", userName='" + userName + '\'' +
", userSex=" + userSex +
'}';
}
}
UserController.java部分代码
@GetMapping("user/get")
public String mysqlGet() {
User user = userDao.selectById(1);
return user.toString();
}