国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專(zhuān)注于服務(wù)器技術(shù)及軟件下載分享
分類(lèi)導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語(yǔ)言|JavaScript|易語(yǔ)言|vb.net|

服務(wù)器之家 - 編程語(yǔ)言 - Java教程 - 解決springboot 多線(xiàn)程使用MultipartFile讀取excel文件內(nèi)容報(bào)錯(cuò)問(wèn)題

解決springboot 多線(xiàn)程使用MultipartFile讀取excel文件內(nèi)容報(bào)錯(cuò)問(wèn)題

2020-09-27 14:36csdn565973850 Java教程

這篇文章主要介紹了解決springboot 多線(xiàn)程使用MultipartFile讀取excel文件內(nèi)容報(bào)錯(cuò)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

springboot項(xiàng)目開(kāi)啟多線(xiàn)程

解決springboot 多線(xiàn)程使用MultipartFile讀取excel文件內(nèi)容報(bào)錯(cuò)問(wèn)題

解決springboot 多線(xiàn)程使用MultipartFile讀取excel文件內(nèi)容報(bào)錯(cuò)問(wèn)題

啟動(dòng)類(lèi)加注解開(kāi)啟 @EnableAsync,實(shí)現(xiàn)類(lèi)方法加注解 @Async

前端頁(yè)面

解決springboot 多線(xiàn)程使用MultipartFile讀取excel文件內(nèi)容報(bào)錯(cuò)問(wèn)題

報(bào)錯(cuò)信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
java.io.FileNotFoundException: C:\Users\dongao\AppData\Local\Temp\tomcat.1255209411477782290.8051\work\Tomcat\localhost\ROOT\upload_7d7b99e5_38da_4a03_93e0_bff20cb48022_00000000.tmp (系統(tǒng)找不到指定的文件。)
 at java.io.FileInputStream.open0(Native Method)
 at java.io.FileInputStream.open(FileInputStream.java:195)
 at java.io.FileInputStream.<init>(FileInputStream.java:138)
 at org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.getInputStream(DiskFileItem.java:194)
 at org.apache.catalina.core.ApplicationPart.getInputStream(ApplicationPart.java:100)
 at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile.getInputStream(StandardMultipartHttpServletRequest.java:250)
 at com.dongao.project.utils.UploadUtil.readExcel(UploadUtil.java:156)
 at com.dongao.project.utils.UploadUtil.readExcelToMap(UploadUtil.java:98)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl.importData(ImportBatchServiceImpl.java:161)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl$$FastClassBySpringCGLIB$$440ed2f6.invoke(<generated>)
 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
 at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
 at com.dongao.support.cat.CatUtils.proceed(CatUtils.java:18)
 at com.dongao.support.cat.CatSpringAop.getObject(CatSpringAop.java:26)
 at com.dongao.support.cat.CatSpringAop.aroundServiceMethod(CatSpringAop.java:22)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
 at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl$$EnhancerBySpringCGLIB$$a16c4d4e.importData(<generated>)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl$$FastClassBySpringCGLIB$$440ed2f6.invoke(<generated>)
 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)
:36:46.137 25472 [threadPoolTaskExecutor-1] INFO com.ruoyi.framework.datasource.DynamicDataSourceContextHolder - [setDataSourceType,26] - 切換到SLAVE數(shù)據(jù)源
:36:46.163 25472 [threadPoolTaskExecutor-1] ERROR org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler - [handleUncaughtException,39] - Unexpected exception occurred invoking async method: public void com.dongao.project.importbatch.service.ImportBatchServiceImpl.importData(org.springframework.web.multipart.MultipartFile,java.lang.Long) throws java.lang.Exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
 at java.util.ArrayList.rangeCheck(ArrayList.java:653)
 at java.util.ArrayList.get(ArrayList.java:429)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl.importData(ImportBatchServiceImpl.java:178)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl$$FastClassBySpringCGLIB$$440ed2f6.invoke(<generated>)
 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
 at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
 at com.dongao.support.cat.CatUtils.proceed(CatUtils.java:18)
 at com.dongao.support.cat.CatSpringAop.getObject(CatSpringAop.java:26)
 at com.dongao.support.cat.CatSpringAop.aroundServiceMethod(CatSpringAop.java:22)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
 at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
 at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl$$EnhancerBySpringCGLIB$$a16c4d4e.importData(<generated>)
 at com.dongao.project.importbatch.service.ImportBatchServiceImpl$$FastClassBySpringCGLIB$$440ed2f6.invoke(<generated>)
 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
 at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)

問(wèn)題分析

前端頁(yè)面?zhèn)鬟^(guò)來(lái)的文件會(huì)存在臨時(shí)文件夾中,如下

C:\Users\dongao\AppData\Local\Temp\tomcat.1255209411477782290.8051\work\Tomcat\localhost\ROOT\

這個(gè)時(shí)候如果單線(xiàn)程操作,即正常程序流程解析是不會(huì)有問(wèn)題的;

如果走異步多線(xiàn)程解析文件,主線(xiàn)程已經(jīng)結(jié)束了,臨時(shí)文件會(huì)被清空,這時(shí)候再來(lái)讀取文件就會(huì)報(bào)錯(cuò)

java.io.FileNotFoundException: C:\Users\dongao\AppData\Local\Temp\tomcat.1255209411477782290.8051\work\Tomcat\localhost\ROOT\upload_7d7b99e5_38da_4a03_93e0_bff20cb48022_00000000.tmp (系統(tǒng)找不到指定的文件。)

問(wèn)題處理

由于主線(xiàn)程結(jié)束,臨時(shí)文件被清空,導(dǎo)致多線(xiàn)程業(yè)務(wù)類(lèi)無(wú)法獲取到臨時(shí)文件而報(bào)錯(cuò)(系統(tǒng)找不到指定的文件。),此時(shí)可以在主線(xiàn)程中轉(zhuǎn)換獲取文件流信息

InputStream is = file.getInputStream();

文件流信息存儲(chǔ)在內(nèi)存中,多線(xiàn)程時(shí)也可以獲取到文件內(nèi)容,解決問(wèn)題。

以上這篇解決springboot 多線(xiàn)程使用MultipartFile讀取excel文件內(nèi)容報(bào)錯(cuò)問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://blog.csdn.net/csdn565973850/article/details/106575090

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 精品国产一级 | 91在线精品一区二区三区 | 午夜视频| 91色乱码一区二区三区 | 国产一区二区久久 | 国产在线一区二区 | 成人av一区二区三区 | 国产毛片v一区二区三区 | 久久一级| 精品久久久久久久久久久久 | 成人国产在线 | 色视频在线 | 亚洲第一视频 | 国产成人精品久久二区二区91 | 亚洲清色| 中文字幕日韩av | 欧美福利视频 | 一a级毛片| 一级片黄色免费 | 国产日韩一区二区三免费高清 | 久久久久久久久一区二区三区 | 亚洲视频区 | 国产美女精品视频免费观看 | 免费在线a | 日日夜夜一区二区 | 国产精品久久久久久久久久久免费看 | 97久久香蕉国产线看观看 | 黄色影视在线免费观看 | 亚洲一区中文字幕在线观看 | 日韩精品www | 亚洲精品一区二区三区在线 | 国产精品美女久久久久久免费 | 在线观看日韩精品 | 亚洲激情在线播放 | 成人亚洲欧美 | 亚洲视频三区 | 亚洲激情综合 | 视频在线一区二区三区 | 国产精品伦理一区二区 | 色135综合网| 欧美综合一区二区三区 |