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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)