weixin_43429839
聆听你的心
采纳率38.5%
2019-09-11 17:14 浏览 737

提示错误Error:(37, 35) java: 不兼容的类型求大佬解答

package com.easy.demo.service;

import com.easy.demo.entity.User;
import com.easy.demo.entity.UserResult;
import com.easy.demo.entity.Userinfo;
import com.easy.demo.mapper.UserMapper;
import com.easy.demo.mapper.UserinfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service(value = "userinfoServer")
public class UserinfoServerImpl implements UserinfoServer {

@Autowired
private UserinfoMapper userinfoMapper;



@Override
public UserResult login(Userinfo userinfo){
    Userinfo u=new Userinfo();
    List<Userinfo> list=new ArrayList<>();
    list= userinfoMapper.login(userinfo);
    UserResult result=new UserResult();
    if (list.size()!=0){
        result.setCode(0);
        result.setMsg("登陆成功");
        result.setList(list);
        result.setObject(list.get(0));
    }else {
        result.setCode(1);
        result.setMsg("登陆失败");
    }
    return result ;
}

}


import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserinfoMapper {

public Userinfo login(Userinfo userinfo);

}


package com.easy.demo.service;

import com.easy.demo.entity.UserResult;
import com.easy.demo.entity.Userinfo;

public interface UserinfoServer {

UserResult login(Userinfo userinfo);

}


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答 默认 最新

  • dabocaiqq dabocaiqq 2019-09-11 18:06
    点赞 评论 复制链接分享
  • hjs218 Json-Huang 2019-09-11 19:26

    完整的错误信息有没有?Error:(37, 35)提示是37行附近可能有问题;
    看了下代码 result.setObject(list.get(0));这行代码中 list.get(0)可能为空,建议debug看下;

    点赞 评论 复制链接分享
  • qq_22847605 qq_22847605 2019-09-12 10:23

    这其实很明显啊,你定义的UserinfoMapper 的 login函数明明返回的是单个对象Userinfo,但你却用List集合对象来接收!!!!

    点赞 评论 复制链接分享

相关推荐