zoukankan      html  css  js  c++  java
  • java.lang.UnsupportedOperationException: A TupleBackedMap cannot be modified.解决以及探究

    java.lang.UnsupportedOperationException: A TupleBackedMap cannot be modified.
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap.put(AbstractJpaQuery.java:390) ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap.put(AbstractJpaQuery.java:323) ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
    at cn.exrick.xboot.modules.system.serviceimpl.FileManageServiceImpl.findNameByFileId(FileManageServiceImpl.java:191) ~[classes/:na]
    at cn.exrick.xboot.modules.system.serviceimpl.FileManageServiceImpl$$FastClassBySpringCGLIB$$72ffea60.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) ~[spring-aop-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295) ~[spring-tx-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at cn.exrick.xboot.modules.system.serviceimpl.FileManageServiceImpl$$EnhancerBySpringCGLIB$$23c87bfa.findNameByFileId(<generated>) ~[classes/:na]
    at cn.exrick.xboot.modules.system.controller.FileManageController.findNameByFileId(FileManageController.java:184) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) ~[spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039) ~[spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) [spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) [spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) [tomcat-embed-core-9.0.19.jar:9.0.19]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) [spring-webmvc-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [tomcat-embed-core-9.0.19.jar:9.0.19]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-9.0.19.jar:9.0.19]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.19.jar:9.0.19]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.19.jar:9.0.19]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.19.jar:9.0.19]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.19.jar:9.0.19]

    这个已经算是我们开发中经常遇到的问题了,其实就是不可操作map的一个异常,解决呢也比较好解决,直接new 一个新的map,将原有的map数据装进去,然后再进行修改,就不会发生异常了,下面先给大家看一下我的原错误代码以及修改后的代码。

    修改前:

    Map<String, Object> nameByFileId = fileManageDao.findNameByFileId(id);
    nameByFileId.put("filePath",imagesUrl+nameByFileId.get("filePath"));
    return nameByFileId;
    

    修改后:

    Map<String, Object> nameByFileId = fileManageDao.findNameByFileId(id);
    Map<String, Object> newMap = new HashMap<>(nameByFileId);
    newMap.put("filePath",imagesUrl+nameByFileId.get("filePath"));
    return newMap;
    

      

  • 相关阅读:
    正则表达式
    iOS设置图片名称、启动图片、防止TabBar图片和文字渲染
    UIImageView中的UIButton不响应事件解决方案
    iOS 适配https
    【如何快速的开发一个完整的iOS直播app】(美颜篇)
    【如何快速的开发一个完整的iOS直播app】(采集篇)
    【如何快速的开发一个完整的iOS直播app】(播放篇)
    【如何快速的开发一个完整的iOS直播app】(原理篇)
    iOS10字体
    AFN 无网络监控
  • 原文地址:https://www.cnblogs.com/zaevn00001/p/12460504.html
Copyright © 2011-2022 走看看