我一直在将框架(spring-ws,spring,spring-batch,hibernate)升级到最新版本。
compile group: 'org.springframework.ws', name: 'spring-ws-core', version: '3.0.4.RELEASE'
compile group: 'org.springframework', name: 'spring-context', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '5.1.1.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '5.1.1.RELEASE'
compile group: 'org.springframework.batch', name: 'spring-batch-core', version: '4.0.1.RELEASE'
compile group: 'org.springframework.batch', name: 'spring-batch-infrastructure', version: '4.0.1.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.6.Final'
除了我执行春季批处理作业时,其他所有内容似乎都可以正常工作
java.lang.NoSuchMethodError: org.hibernate.StatelessSession.createQuery(Ljava/lang/String;)Lorg/hibernate/query/Query;
at org.springframework.batch.item.database.HibernateItemReaderHelper.createQuery(HibernateItemReaderHelper.java:148)
at org.springframework.batch.item.database.HibernateItemReaderHelper.getForwardOnlyCursor(HibernateItemReaderHelper.java:122)
at org.springframework.batch.item.database.HibernateCursorItemReader.doOpen(HibernateCursorItemReader.java:185)
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:146)
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:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy50.open(Unknown Source)
at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:103)
at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:310)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:197)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:66)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:136)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:308)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:141)
at java.lang.Thread.run(Thread.java:748)
我看到HibernateItemReaderHelper调用了createQuery方法,在该方法内部,调用了StatelessSession的createQuery方法。
HibernateItemReaderHelper.creatQuery返回org.hibernate.query.Query对象; StatelessSession.createQuery返回org.hibernate.Query的对象
我认为这是问题所在,但是我该如何解决? 请帮助
答案 0 :(得分:1)
Spring Batch Core 4.0.1.RELEASE 似乎与 Hibernate 5.2.12.Final as can be seen in its tag build.gradle dependency file兼容,因此请尝试一下,而不是您的显式版本 5.3.6.Final 。