首页 新闻 搜索 专区 学院

求助,手机请求后台数据的时候出现

0
悬赏园豆:100 [已解决问题] 解决于 2016-12-20 20:04

求助,手机请求后台数据的时候出现org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface错误,后台用的是Spring框架,手机端用的retrofit ,而且代码中的List已经改成了JSON字符串

软件杨威的主页 软件杨威 | 初学一级 | 园豆:26
提问于:2016-12-20 14:41
< >
分享
最佳答案
0

.....看着就知道你是要把数据反序列化成接口吧...想什么呢.

收获园豆:100
吴瑞祥 | 高人七级 |园豆:29187 | 2016-12-20 14:43

是类,不是接口,这是我Controller

@Controller
@RequestMapping("shoppingcart")
public class ShoppingCartController {
    @Autowired
    private ShoppingCartService shoppingCartService;
    
    @RequestMapping("addshoppingcart")
    @ResponseBody
    public boolean addShoppingCartGood(@RequestBody ShoppingCartGood shoppingCartGood,String buyerUserId){
        boolean isAddShoppingCartSuccess=shoppingCartService.addGoodToCart(shoppingCartGood, buyerUserId);
        return isAddShoppingCartSuccess;
    }
    
    @RequestMapping("findshoppingcart")
    @ResponseBody
    public List<ShoppingCartGood> findShoppingCartGood(String buyerUserId,int page,int size){
        List<ShoppingCartGood> shoppingCartGoodList=shoppingCartService.queryShoppingCartGood(buyerUserId, page, size);
        return shoppingCartGoodList;
    }
    
    @RequestMapping("deleteshoppingcart")
    @ResponseBody
    public boolean deleteShoppingCartGood(String shoppingCartGoodIdJSON){
        boolean isDeleteSuccess=shoppingCartService.deleteCartGood(shoppingCartGoodIdJSON);
        return isDeleteSuccess;
    }
}

下面是我的类

public class ShoppingCartGood extends Good{

    private int storeId;                //商店Id
    private int goodNumber;                //商品数量
    
    public ShoppingCartGood() {
        super();
    }

    public ShoppingCartGood(int storeId, int goodNumber) {
        super();
        this.storeId     = storeId;
        this.goodNumber = goodNumber;
    }

    public int getStoreId() {
        return storeId;
    }
    public void setStoreId(int storeId) {
        this.storeId = storeId;
    }
    public int getGoodNumber() {
        return goodNumber;
    }
    public void setGoodNumber(int goodNumber) {
        this.goodNumber = goodNumber;
    }
}

 

软件杨威 | 园豆:26 (初学一级) | 2016-12-20 14:52

而且,我在Controller中是直接把数据传递过去,断点的时候是Controller不走,三个方法中中间的那个是没有问题的,第一个第三个不行

软件杨威 | 园豆:26 (初学一级) | 2016-12-20 15:18

@软件杨威: 前面抛出的异常还是后台抛出的异常.异常在哪一行.

吴瑞祥 | 园豆:29187 (高人七级) | 2016-12-20 15:20

@吴瑞祥: 手机端直接返回到上一界面,后台报的这个错误,没有说是哪一行

软件杨威 | 园豆:26 (初学一级) | 2016-12-20 15:23

@软件杨威: 打日志吧.先定位异常在哪一行再解决.

吴瑞祥 | 园豆:29187 (高人七级) | 2016-12-20 15:25

@吴瑞祥: 

严重: Servlet.service() for servlet [mvc] in context with path [/FreeUniversityServer] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface] with root cause
org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:99)
    at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:142)
    at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:80)
    at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:102)
    at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
    at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

这是我的错误,后台直接是不走这个方法,前台是封装的retrofit,结果的response的body直接是null,

软件杨威 | 园豆:26 (初学一级) | 2016-12-20 15:29

@软件杨威: 把ShoppingCartGood这个类改成poco看看咯.或者改个返回值看看.是不是这个类型有问题.

吴瑞祥 | 园豆:29187 (高人七级) | 2016-12-20 15:31

@吴瑞祥: 我再改改这个类试试,返回值改过没用

软件杨威 | 园豆:26 (初学一级) | 2016-12-20 15:34

一个错误出现在这儿很无奈,搞了很长时间,JSON的jar包没有导全,全导进去之后就好了

软件杨威 | 园豆:26 (初学一级) | 2016-12-20 20:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册