springjpa⼀个类型转换错误的解决⽅案
报错如下.
Error starting ApplicationContext. To display the conditions report re-run your application with'debug' enabled.
2021-08-2513:42:32.004 ERROR 11168---[  restartedMain]SpringApplication              : Application run failed
IllegalStateException: Failed to ApplicationRunner
at SpringApplication.callRunner(SpringApplication.java:785)~[spring-boot-2.5.4.jar:2.5.4]
at SpringApplication.callRunners(SpringApplication.java:772)~[spring-boot-2.5.4.jar:2.5.4]
at SpringApplication.run(SpringApplication.java:345)~[spring-boot-2.5.4.jar:2.5.4]
at SpringApplication.run(SpringApplication.java:1343)~[spring-boot-2.5.4.jar:2.5.4]
at SpringApplication.run(SpringApplication.java:1332)~[spring-boot-2.5.4.jar:2.5.4]
at App.main(App.java:14)~[classes/:na]
at java.base/NativeMethodAccessorImpl.invoke0(Native Method)~[na:na]
at java.base/NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)~[na:na]
at java.base/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)~[na:na]
at java.base/Method.invoke(Method.java:567)~[na:na]
at RestartLauncher.run(RestartLauncher.java:49)~[spring-boot-devtools-2.5.4.jar:2.5.4]
Caused by:ConversionFailedException: Failed to from type [Object[]]to[@org.springframework.d pository.Query SuanLiFenPeiConfig]for value '{732, 0, JQ1, 3}'; nested exception is Conv
erterNotFoundException: No converter found capable of converting from type [Integer]to[@org.spring
framework.pository.Query SuanLiFenPeiConfig]
at ConversionUtils.invokeConverter(ConversionUtils.java:47)~[spring-core-5.3.9.jar:5.3.9]
vert(GenericConversionService.java:192)~[spring-core-5.3.9.jar:5.3.9]
vert(CollectionToCollectionConverter.java:89)~[spring-core-5.3.9.ja r:5.3.9]
at ConversionUtils.invokeConverter(ConversionUtils.java:41)~[spring-core-5.3.9.jar:5.3.9]
vert(GenericConversionService.java:192)~[spring-core-5.3.9.jar:5.3.9]
vert(GenericConversionService.java:213)~[spring-core-5.3.9.jar:5.3.9]
at QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java: 167)
~[spring-data-commons-2.5.4.jar:2.5.4]
at QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java: 77)~[spring-data-commons-2.5.4.jar:2.5.4]
at QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)~[spring-da ta-commons-2.5.4.jar:2.5.4]
at ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)~[spring-aop-5.3.9.jar:5.3.9]
at DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)~[spring-d ata-commons-2.5.4.jar:2.5.4]
at ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)~[spring-aop-5.3.9.jar:5.3.9]
at TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)~[spring-tx-5.3.9.jar :5.3.9]
at TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)~[spring-tx-5.
3.9.jar:5.3.9]
at TransactionInterceptor.invoke(TransactionInterceptor.java:119)~[spring-tx-5.3.9.jar:5.3.9]
at ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)~[spring-aop-5.3.9.jar:5.3.9]
at PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)~[sprin g-tx-5.3.9.jar:5.3.9]
at ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)~[spring-aop-5.3.9.jar:5.3.9]
at CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(C rudMethodMetadataPostProcessor.java:145)~[spring-data-jpa-2.5.4.jar:2.5.4]
at ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)~[spring-aop-5.3.9.jar:5.3.9]
at ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)~[spring-aop-5.3.9.jar:5.3.9]
at ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)~[spring-aop-5.3.9.jar:5.3.9]
springboot aop
at JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)~[spring-aop-5.3.9.jar:5.3.9]
at jdk.proxy4/jdk.proxy4.$Proxy94.FindByComputer_num(Unknown Source)~[na:na]
at SuanLiFenPeiConfigService.FindByComputer_num(SuanLiFenPeiConfigService.java:64)~[classes/:na]
at MQConsumer.Q_WebAPI_TakeImage_on_WCMS_CMDTakeImage.run(Q_WebAPI_TakeImage_on_WCMS_CMDTakeImage.java:141)~ [classes/:na]
at SpringApplication.callRunner(SpringApplication.java:782)~[spring-boot-2.5.4.jar:2.5.4]
...10 common frames omitted
Caused by:ConverterNotFoundException: No converter found capable of converting from type [Integer]to [@org.springframework.pository.Query SuanLiFenPeiConfig]
[@org.springframework.pository.Query SuanLiFenPeiConfig]
at GenericConversionService.handleConverterNotFound(GenericConversionService.java:322)~[spring-cor e-5.3.9.jar:5.3.9]
vert(GenericConversionService.java:195)~[spring-core-5.3.9.jar:5.3.9]        vert(ArrayToObjectConverter.java:68)~[spring-core-5.3.9.jar:5.3.9]
at ConversionUtils.invokeConverter(ConversionUtils.java:41)~[spring-core-5.3.9.jar:5.3.9] ...36 common frames omitted
2021-08-2513:42:32.081  INFO 11168---[  restartedMain]LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistenc e unit 'default'
解决⽅案
如果l中同时包含了spring boot的包, ⼜包含了hibernate的包.
那么会出现上⾯的错误. 解决⽅案很简单 把l中 关于hibernate的包去掉
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Alpha9</version>
</dependency>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。