Springboot项目启动错误一

1、Consider defining a bean of type 'com.yc.ux.dao.UserMapper' in your configuration

没有在接口上添加@Mapper注解

@Mapper
@Component
public interface UserMapper {

2、org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

检查mybatis.mapper-locations是否正确

mybatis.mapper-locations=classpath:/mapper/*.xml

3、java.lang.IllegalArgumentException: No converter found for return value of type: class com.yc.ux.entity.User

  • 检查是否有注解@RestController
@RestController
@RequestMapping("hello")
public class HelloController {
  • 检查是否有注解@Controller+@ReponseBody
@Controller
@RequestMapping("hello")
public class HelloController {
    
    @ResponseBody
    @RequestMapping("user")
    public User getUser(){
        return helloService.getUserInfos();
    }
}
  • 检查方法返回类型的类中是否有getset方法
@RequestMapping("user")
public User getUser(){
  return helloService.getUserInfos();
}

public class User {
    private String id;

    private String name;

    private String password;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}

 

 

 

 

 

 

你可能感兴趣的:(springboot)