分布式网上商城项目-图片上传及删除功能错误

Posted floatthy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了分布式网上商城项目-图片上传及删除功能错误相关的知识,希望对你有一定的参考价值。

 

1、自己创建的jar包导入本地仓库引用后出现错误

 

 1 [ERROR] [ERROR] Some problems were encountered while processing the POMs:
 2 
 3 [WARNING] ‘dependencies.dependency.(groupId:artifactId:type:classifier)‘ must be unique: org.apache.commons:commons-io:jar -> duplicate declaration of version (?) @ line 66, column 21
 4 
 5 [ERROR] ‘dependencies.dependency.version‘ for fastdfs_client:fastdfs_client:jar is missing. @ line 58, column 21
 6 
 7  @
 8 
 9 [ERROR] The build could not read 1 project -> [Help 1]
10 
11 [ERROR]  
12 
13 [ERROR]   The project cn.thyonline:taotao-common:0.0.1-SNAPSHOT (D:\application\taotao\taotao-common\pom.xml) has 1 error
14 
15 [ERROR]     ‘dependencies.dependency.version‘ for fastdfs_client:fastdfs_client:jar is missing. @ line 58, column 21
16 
17 [ERROR]
18 
19 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
20 
21 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
22 
23 [ERROR]
24 
25 [ERROR] For more information about the errors and possible solutions, please read the following articles:
26 
27 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

 不知道为什么父pom文件里面声明的版本号没有生效,在对应的子pom文件添加版本号之后这个错误就消失了

 

2、数据MultipartFile在dubbo中传递的错误

 

  1 严重: Servlet.service() for servlet [taotao-manager-web] in context with path [] threw exception [Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method uploadPic in the service cn.thyonline.taotao.service.PictureService. Tried 3 times of the providers [192.168.199.139:20880] (1/1) from the registry 192.168.25.128:2181 on the consumer 192.168.199.139 using the dubbo version 2.5.3. Last error is: Failed to invoke remote method: uploadPic, provider: dubbo://192.168.199.139:20880/cn.thyonline.taotao.service.PictureService?anyhost=true&application=taotao-manager-web&check=false&dubbo=2.5.3&interface=cn.thyonline.taotao.service.PictureService&methods=uploadPic&pid=6968&revision=0.0.1-SNAPSHOT&side=consumer&timestamp=1528043711358, cause: Fail to decode request due to: RpcInvocation [methodName=uploadPic, parameterTypes=null, arguments=null, attachments={path=cn.thyonline.taotao.service.PictureService, input=964, dubbo=2.5.3, version=0.0.0}]] with root cause
  2 
  3 com.alibaba.dubbo.remoting.RemotingException: Fail to decode request due to: RpcInvocation [methodName=uploadPic, parameterTypes=null, arguments=null, attachments={path=cn.thyonline.taotao.service.PictureService, input=964, dubbo=2.5.3, version=0.0.0}]
  4 
  5          at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.returnFromResponse(DefaultFuture.java:190)
  6 
  7          at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:110)
  8 
  9          at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:84)
 10 
 11          at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96)
 12 
 13          at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144)
 14 
 15          at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74)
 16 
 17          at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
 18 
 19          at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 20 
 21          at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53)
 22 
 23          at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 24 
 25          at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48)
 26 
 27          at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
 28 
 29          at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
 30 
 31          at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77)
 32 
 33          at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227)
 34 
 35          at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72)
 36 
 37          at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
 38 
 39          at com.alibaba.dubbo.common.bytecode.proxy2.uploadPic(proxy2.java)
 40 
 41          at cn.thyonline.taotao.controller.PictureController.uploadFile(PictureController.java:26)
 42 
 43          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 44 
 45          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 46 
 47          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 48 
 49          at java.base/java.lang.reflect.Method.invoke(Method.java:564)
 50 
 51          at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
 52 
 53          at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
 54 
 55          at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
 56 
 57          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
 58 
 59          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
 60 
 61          at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
 62 
 63          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
 64 
 65          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
 66 
 67          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
 68 
 69          at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:871)
 70 
 71          at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
 72 
 73          at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
 74 
 75          at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
 76 
 77          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 78 
 79          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 80 
 81          at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
 82 
 83          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 84 
 85          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 86 
 87          at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
 88 
 89          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 90 
 91          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 92 
 93          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 94 
 95          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
 96 
 97          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
 98 
 99          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
100 
101          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
102 
103          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
104 
105          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
106 
107          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
108 
109          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
110 
111          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
112 
113          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
114 
115          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
116 
117          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
118 
119          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
120 
121          at java.base/java.lang.Thread.run(Thread.java:844)

 

 检查发现dubbo的引用服务和发布服务的设定都没问题。但是picFile这个方法就是传递不到。这些都没问题,问题只可能是传递的数据MultipartFile不支持dubbo的这种传递方式。于是我把保存图片的方法写到controller层。运行成功~

 

3、后台无法接收到js传来的数据

 

 1 text:‘删除‘,
 2 
 3         iconCls:‘icon-cancel‘,
 4 
 5         handler:function(){
 6 
 7             var ids = getSelectionsIds();
 8 
 9             if(ids.length == 0){
10 
11                 $.messager.alert(‘提示‘,‘未选中商品!‘);
12 
13                 return ;
14 
15             }
16 
17             $.messager.confirm(‘确认‘,‘确定删除ID为 ‘+ids+‘ 的商品吗?‘,function(r){
18 
19                 if (r){
20 
21                     var params = {"ids":ids};
22 
23                     $.post("/rest/item/delete",params, function(data){
24 
25                         if(data.status == 200){
26 
27                             $.messager.alert(‘提示‘,‘删除商品成功!‘,undefined,function(){
28 
29                                 $("#itemList").datagrid("reload");
30 
31                             });
32 
33                         }
34 
35                     });
36 
37                 }
38 
39             });
40 
41         }

改成对应的数据则删除成功,说明在后端接收数据的时候需要指定数据类型和数据的名称,才能正确接收到数据在做删除的功能时,后台使用Long id和string id都无法接收到数据。查看jQuery页面的时候发现页面传到后台的数据为String ids。

以上是关于分布式网上商城项目-图片上传及删除功能错误的主要内容,如果未能解决你的问题,请参考以下文章

TinyMCE的使用(包括汉化及本地图片上传功能)

(转)淘淘商城系列——实现图片上传功能

php表单上传图片到七牛云存储并返回地址……求具体流程~有代码更好

html + js 实现图片上传,压缩,预览及图片压缩后得到Blob对象继续上传问题

Java网络商城项目 SpringBoot+SpringCloud+Vue 网络商城(SSM前后端分离项目)九(设置nginx保存图片的代理路径,修改和删除品牌)

分布式网上商城项目-项目查询功能错误