shell33168 2017-09-16 02:30 采纳率: 0%
浏览 2643

spring框架报错binding.BindingException

报错:
```org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.nowcoder.toutiao.dao.NewsDAO.selectByUserIdAndOffset
at org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:214) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:48) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) ~[mybatis-3.4.0.jar:3.4.0]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) ~[mybatis-3.4.0.jar:3.4.0]
at com.sun.proxy.$Proxy60.selectByUserIdAndOffset(Unknown Source) ~[na:na]
at com.nowcoder.toutiao.servicr.NewsService.getLatestNews(NewsService.java:16) ~[classes/:na]
at com.nowcoder.toutiao.controller.HomeController.index(HomeController.java:30) ~[classes/:na]

其中 NewsService.java
package com.nowcoder.toutiao.servicr;

import com.nowcoder.toutiao.dao.NewsDAO;
import com.nowcoder.toutiao.model.News;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsService {
    @Autowired
    private NewsDAO newsDAO;

    public List<News> getLatestNews(int userId,int offset,int limit){
        return newsDAO.selectByUserIdAndOffset(userId,offset,limit);
    }
}


HomeController代码:
package com.nowcoder.toutiao.controller;

import com.nowcoder.toutiao.dao.NewsDAO;
import com.nowcoder.toutiao.model.News;
import com.nowcoder.toutiao.model.ViewObject;
import com.nowcoder.toutiao.servicr.NewsService;
import com.nowcoder.toutiao.servicr.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jws.WebParam;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
@Controller
public class HomeController{
    @Autowired
    NewsService newsService;

    @Autowired
    UserService userService;


    @RequestMapping(path={"/","/index"},method={RequestMethod.GET,RequestMethod.POST})
    public String index(Model model){
        List<News> newsList=newsService.getLatestNews(0,0,10);
        List<ViewObject> vos=new ArrayList<>();
        for (News news:newsList){
            ViewObject vo=new ViewObject();
            vo.set("news",news);//vo里面可以放任何东西
            vo.set("user",userService.getUser(news.getUserId()));
            vos.add(vo);
        }
        model.addAttribute("vos",vos);
        return "home";
    }

}







  • 写回答

4条回答

  • linmintc 2017-09-16 02:45
    关注

    DAOMampper.xml文件出错了

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建