D:\projectdev\image\D:\TuPian\items\shop\49.JPEG (文件名、目录名或卷标语法不正确。)

来源:4-5 店铺注册之Service层的实现

慕田峪2175044

2018-06-11

2018-06-11 15:06:55.976 [main] DEBUG com.imooc.o2o.dao.ShopDao.insertShop - ==>  Preparing: INSERT INTO tb_shop (owner_id,area_id,shop_category_id,shop_name, shop_desc,shop_addr,phone,shop_img,priority,create_time, last_edit_time,enable_status,advice) VALUES (?,?, ?,?, ?,?,?,?, ?,?,?, ?,?) 

2018-06-11 15:06:56.014 [main] DEBUG com.imooc.o2o.dao.ShopDao.insertShop - ==> Parameters: 1(Long), 2(Integer), 11(Long), 测试的sk店铺(String), test(String), test(String), test(String), null, null, 2018-06-11 15:06:55.951(Timestamp), 2018-06-11 15:06:55.951(Timestamp), 0(Integer), 审核中(String)

2018-06-11 15:06:56.016 [main] DEBUG com.imooc.o2o.dao.ShopDao.insertShop - <==    Updates: 1

2018-06-11 15:06:56.025 [main] DEBUG com.imooc.o2o.until.ImageUtil - current relativeAddr isD:\TuPian\items\shop\49\2018061115065698879.jpg

2018-06-11 15:06:56.025 [main] DEBUG com.imooc.o2o.until.ImageUtil - current completeAddr isD:\projectdev\image\D:\TuPian\items\shop\49\2018061115065698879.jpg

2018-06-11 15:06:56.188 [main] ERROR com.imooc.o2o.until.ImageUtil - java.io.FileNotFoundException: D:\projectdev\image\D:\TuPian\items\shop\49.JPEG (文件名、目录名或卷标语法不正确。)

java.io.FileNotFoundException: D:\projectdev\image\D:\TuPian\items\shop\49.JPEG (文件名、目录名或卷标语法不正确。)

at java.io.FileOutputStream.open0(Native Method)

at java.io.FileOutputStream.open(FileOutputStream.java:270)

at java.io.FileOutputStream.<init>(FileOutputStream.java:213)

at java.io.FileOutputStream.<init>(FileOutputStream.java:162)

at net.coobird.thumbnailator.tasks.io.FileImageSink.write(Unknown Source)

at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.write(Unknown Source)

at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)

at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)

at com.imooc.o2o.until.ImageUtil.generateThumbnail(ImageUtil.java:63)

at com.imooc.o2o.service.impl.ShopServiceImpl.addShopImg(ShopServiceImpl.java:64)

at com.imooc.o2o.service.impl.ShopServiceImpl.addShop(ShopServiceImpl.java:43)

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.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)

at com.sun.proxy.$Proxy23.addShop(Unknown Source)

at com.imooc.o2o.service.ShopServiceTest.testAddShop(ShopServiceTest.java:43)

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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

2018-06-11 15:06:56.221 [main] DEBUG com.imooc.o2o.dao.ShopDao.updateShop - ==>  Preparing: update tb_shop SET shop_name=?, shop_desc=?, shop_addr=?, phone=?, shop_img=?, last_edit_time=?, enable_status=?, advice=?, area_id=?, shop_category_id=? where shop_id=? 


写回答

1回答

翔仔

2018-06-11

同学好,错误非常明确啊,

D:\projectdev\image\D:\TuPian\items\shop\49.JPEG 

你的这个文件路径并不存在,你可以调试一下,看看你实际存储的文件路径为什么是这个,我猜你用了绝对值路径去弄外加我们写死了的前缀路径D:\projectdev\image,导致保存图片的时候报错,请仔细检查。此类问题希望同学能借此培养独立解决问题的能力:)

0
3
慕田峪2175044
回复
翔仔
感谢翔哥,找到了,public static String getShopImagePath(long shopId){ String imagePath = "D:/TuPian/items/shop/"+shopId+"/"; return imagePath.replace("/",seperator); } 这个地方不应该写 D: 还是文件流与操作系统不太懂。
2018-06-11
共3条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5127 学习 · 8148 问题

查看课程