请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

添加图片失败,添加店铺失败

老师你好!我现在的问题是添加图片失败,添加店铺失败。

十一月 17, 2019 5:28:12 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
十一月 17, 2019 5:28:12 下午 org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
信息: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@2ed94a8b, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@38082d64, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@dfd3711, org.springframework.test.context.support.DirtiesContextTestExecutionListener@42d3bd8b, org.springframework.test.context.transaction.TransactionalTestExecutionListener@26ba2a48, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@5f2050f6]
十一月 17, 2019 5:28:12 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-dao.xml]
十一月 17, 2019 5:28:12 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-service.xml]
十一月 17, 2019 5:28:13 下午 org.springframework.context.support.GenericApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.GenericApplicationContext@23ceabc1: startup date [Sun Nov 17 17:28:13 CST 2019]; root of context hierarchy
十一月 17, 2019 5:28:13 下午 com.mchange.v2.log.MLog <clinit>
信息: MLog clients using java 1.4+ standard logging.
十一月 17, 2019 5:28:13 下午 com.mchange.v2.c3p0.C3P0Registry banner
信息: Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
十一月 17, 2019 5:28:13 下午 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 3, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 3000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 2x5x8fa6xhju5z1s88c2c|6b81ce95, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2x5x8fa6xhju5z1s88c2c|6b81ce95, idleConnectionTestPeriod -> 60, initialPoolSize -> 5, jdbcUrl -> jdbc:mysql://localhost:3306/o2o?useUnicode=true&characterEncoding=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 60, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 30, maxStatements -> 100, maxStatementsPerConnection -> 3, minPoolSize -> 10, numHelperThreads -> 3, preferredTestQuery -> select1, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
2019-11-17 17:28:14.119 [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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) 
2019-11-17 17:28:14.145 [main] DEBUG com.imooc.o2o.dao.ShopDao.insertShop -==> Parameters: 1(Long), 2(Integer), 1(Long), 测试的店铺1(String), test1(String), test1(String), test1(String), null, null, 2019-11-17 17:28:14.103(Timestamp), 2019-11-17 17:28:14.103(Timestamp), 0(Integer), 审核中(String)
2019-11-17 17:28:14.155 [main] DEBUG com.imooc.o2o.dao.ShopDao.insertShop -<==    Updates: 1
十一月 17, 2019 5:28:14 下午 org.springframework.context.support.GenericApplicationContext doClose
信息: Closing org.springframework.context.support.GenericApplicationContext@23ceabc1: startup date [Sun Nov 17 17:28:13 CST 2019]; root of context hierarchy

com.imooc.o2o.exceptions.ShopOperationException: addShop error:addShopImg error:Cannot format given Object as a Date
	at com.imooc.o2o.service.impl.ShopServiceImpl.addShop(ShopServiceImpl.java:56)
	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:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)


正在回答

3回答

翔仔 2019-11-18 00:28:07

同学好,感觉是你的时间类型处理有问题,可能是传入的createTime或者lastEditTime有问题,导致转Date的时候有问题

https://blog.csdn.net/lovexiaoxiao/article/details/8931391


1 回复 有任何疑惑可以回复我~
  • 提问者 草田光日天 #1
    非常感谢!
    回复 有任何疑惑可以回复我~ 2019-11-18 22:38:42
提问者 草田光日天 2019-11-19 11:40:16

好的老师,那个“\”是执行Junit自动改的,我代码里是“/”的。完整问题是

十一月 19, 2019 11:28:42 上午 org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
十一月 19, 2019 11:28:42 上午 org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
信息: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@2ed94a8b, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@38082d64, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@dfd3711, org.springframework.test.context.support.DirtiesContextTestExecutionListener@42d3bd8b, org.springframework.test.context.transaction.TransactionalTestExecutionListener@26ba2a48, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@5f2050f6]
十一月 19, 2019 11:28:42 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-dao.xml]
十一月 19, 2019 11:28:42 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/spring-service.xml]
十一月 19, 2019 11:28:42 上午 org.springframework.context.support.GenericApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.GenericApplicationContext@23ceabc1: startup date [Tue Nov 19 11:28:42 CST 2019]; root of context hierarchy
十一月 19, 2019 11:28:43 上午 com.mchange.v2.log.MLog <clinit>
信息: MLog clients using java 1.4+ standard logging.
十一月 19, 2019 11:28:43 上午 com.mchange.v2.c3p0.C3P0Registry banner
信息: Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
十一月 19, 2019 11:28:43 上午 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 3, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 3000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 2x5x8fa6zzl7vt19xuxmr|6b81ce95, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2x5x8fa6zzl7vt19xuxmr|6b81ce95, idleConnectionTestPeriod -> 60, initialPoolSize -> 5, jdbcUrl -> jdbc:mysql://localhost:3306/o2o?useUnicode=true&characterEncoding=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 60, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 30, maxStatements -> 100, maxStatementsPerConnection -> 3, minPoolSize -> 10, numHelperThreads -> 3, preferredTestQuery -> select1, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
2019-11-19 11:28:44.011 [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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) 
2019-11-19 11:28:44.037 [main] DEBUG com.imooc.o2o.dao.ShopDao.insertShop -==> Parameters: 1(Long), 2(Integer), 1(Long), 测试的店铺1(String), test1(String), test1(String), test1(String), null, null, 2019-11-19 11:28:43.994(Timestamp), 2019-11-19 11:28:43.994(Timestamp), 0(Integer), 审核中(String)
2019-11-19 11:28:44.039 [main] DEBUG com.imooc.o2o.dao.ShopDao.insertShop -<==    Updates: 1
2019-11-19 11:28:44.045 [main] DEBUG com.imooc.o2o.util.ImageUtil -目前相对路径是:shop\54\2019111911284445109.jpg
2019-11-19 11:28:44.045 [main] DEBUG com.imooc.o2o.util.ImageUtil -目前完整路径是:E:\testo2o\image\shop\54\2019111911284445109.jpg
2019-11-19 11:28:44.128 [main] ERROR com.imooc.o2o.util.ImageUtil -java.io.FileNotFoundException: E:\testo2o\image\shop\54\2019111911284445109.jpg (系统找不到指定的路径。)
java.io.FileNotFoundException: E:\testo2o\image\shop\54\2019111911284445109.jpg (系统找不到指定的路径。)
	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.util.ImageUtil.generateThumbnail(ImageUtil.java:65)
	at com.imooc.o2o.service.impl.ShopServiceImpl.addShopImg(ShopServiceImpl.java:64)
	at com.imooc.o2o.service.impl.ShopServiceImpl.addShop(ShopServiceImpl.java:44)
	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:44)
	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:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
2019-11-19 11:28:44.149 [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 = ? 
2019-11-19 11:28:44.150 [main] DEBUG com.imooc.o2o.dao.ShopDao.updateShop -==> Parameters: 测试的店铺1(String), test1(String), test1(String), test1(String), shop\54\2019111911284445109.jpg(String), 2019-11-19 11:28:43.994(Timestamp), 测试的店铺1(String), 审核中(String), 2(Integer), 1(Long), 54(Long)
十一月 19, 2019 11:28:44 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
十一月 19, 2019 11:28:44 上午 org.springframework.jdbc.support.SQLErrorCodesFactory <init>
信息: SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
Junit的:

com.imooc.o2o.exceptions.ShopOperationException: addShop error:
### Error updating database.  Cause: java.sql.SQLException: Incorrect integer value: '测试的店铺1' for column 'enable_status' at row 1
### The error may involve com.imooc.o2o.dao.ShopDao.updateShop-Inline
### The error occurred while setting parameters
### SQL: 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 = ?
### Cause: java.sql.SQLException: Incorrect integer value: '测试的店铺1' for column 'enable_status' at row 1
; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1366]; Incorrect integer value: '测试的店铺1' for column 'enable_status' at row 1; nested exception is java.sql.SQLException: Incorrect integer value: '测试的店铺1' for column 'enable_status' at row 1
	at com.imooc.o2o.service.impl.ShopServiceImpl.addShop(ShopServiceImpl.java:56)
	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:44)
	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:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)


0 回复 有任何疑惑可以回复我~
  • 翔仔 #1
    同学好,首先,程序不会如此"智能",也就是说不可能自己会改,需要同学设置断点,一步步调试一下,会发现是我们使用了seperator这个变量来替换掉了/,所以可以直接把separator改成/即可。另外一个问题,E:\testo2o\image\shop\54\2019111911284445109.jpg (系统找不到指定的路径。)说的就是找不到E:\testo2o\image\shop\54\2019111911284445109.jpg这张图片,所以请确保这张图片存在。然后最后一个问题,同学的mapper里面的sql写的有问题update tb_shop       SET shop_name=?,       shop_desc=?,       shop_addr=?,       phone = ?,       shop_img=?,               Cause: java.sql.SQLException: Incorrect integer value: '测试的店铺1' for column 'enable_status' at row 1 ,       非常明显,你把value: '测试的店铺1' 赋值给enable_status 肯定不对呀,enable_status接受的是整型,所以你需要检查一下你的语句是读取Shop里的哪个字段的,也即你的mapper写错了。
    回复 有任何疑惑可以回复我~ 2019-11-19 23:55:22
  • 提问者 草田光日天 回复 翔仔 #2
    谢谢老师的解惑!都解决了。谢谢
    回复 有任何疑惑可以回复我~ 2019-11-20 17:49:48
提问者 草田光日天 2019-11-18 22:50:33

谢谢老师,我还有一个问题不太明白,我也看了其他同学相同的提问,还是看不明白,脑子太笨了

2019-11-18 22:37:53.366 [main] DEBUG com.imooc.o2o.util.ImageUtil -目前相对路径是:\shop\50\2019111822375317617.jpg
2019-11-18 22:37:53.367 [main] DEBUG com.imooc.o2o.util.ImageUtil -目前完整路径是:E:\testo2o\image\shop\50\2019111822375317617.jpg
2019-11-18 22:37:53.456 [main] ERROR com.imooc.o2o.util.ImageUtil -java.io.FileNotFoundException: E:\testo2o\image\shop\50\2019111822375317617.jpg (系统找不到指定的路径。)
java.io.FileNotFoundException: E:\testo2o\image\shop\50\2019111822375317617.jpg (系统找不到指定的路径。)

我之前添加水印并压缩图片的测试都成功,现在service就找不到路径。上传路径是E:\textJava\image\L.jpg,保存路径是E:\testo2o\image\shop\50\2019111822375317617.jpg,这个路径不是说自动生成的吗,怎么提示找不到的?

0 回复 有任何疑惑可以回复我~
  • 翔仔 #1
    同学好,这个就需要同学调试一下了,光这样描述我这边也没法精确定位问题,应该是你存储的时候写入的路径没有找到。此外,建议同学全部使用/替代\,因为最新的win和linux都支持路径/了,没必要使用separator来区分
    回复 有任何疑惑可以回复我~ 2019-11-19 00:15:16
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信