我正在尝试从excel文件读取并将它们映射到一个对象中并将其存储在数据库中,并且我已经从com.github.deanwong中手动下载了excel的spring jar文件
<dependency>
<groupId>com.github.deanwong</groupId>
<artifactId>spring-batch-excel</artifactId>
<version>0.5.5</version>
</dependency>
因此在步骤1中,它会遇到此执行
严重:作业因错误终止:
Error creating bean with name 'step1': Cannot resolve reference to bean 'customerItemReader' while setting bean property 'itemReader'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.batch.item.excel.poi.PoiItemReader] for bean with name 'customerItemReader' defined in class path resource [spring/batch/jobs/excelreader.xml]: problem with class file or dependent class; nested exception is java.lang.VerifyError: class org.springframework.batch.item.excel.AbstractExcelItemReader overrides final method org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read()Ljava/lang/Object;
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step1': Cannot resolve reference to bean 'customerItemReader' while setting bean property 'itemReader'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.batch.item.excel.poi.PoiItemReader] for bean with name 'customerItemReader' defined in class path resource [spring/batch/jobs/excelreader.xml]: problem with class file or dependent class; nested exception is java.lang.VerifyError: class org.springframework.batch.item.excel.AbstractExcelItemReader overrides final method org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read()Ljava/lang/Object;
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:284)
at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:577)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.batch.item.excel.poi.PoiItemReader] for bean with name 'customerItemReader' defined in class path resource [spring/batch/jobs/excelreader.xml]: problem with class file or dependent class; nested exception is java.lang.VerifyError: class org.springframework.batch.item.excel.AbstractExcelItemReader overrides final method org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read()Ljava/lang/Object;
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1272)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:438)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinion
我的xml文件是
<batch:job id="customerJob">
<batch:step id="step1">
<batch:tasklet>
<batch:chunk reader="customerItemReader" writer="mysqlItemWriter"
processor="customerItemProcessor" commit-interval="1000">
</batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
<bean class="com.shoppers.sales.util.ExtendPropertySourcesPlaceholderConfigurer">
<property name="overridingSource"
value="${propertyPath}" />
</bean>
<bean id="customerItemReader" class="org.springframework.batch.item.excel.poi.PoiItemReader">
<property name="linesToSkip" value="1" />
<property name="resource" value="#{'file:'+'${upload_path}'+'${customer_file}'}" />
<property name="rowMapper">
<bean class="org.springframework.batch.item.excel.mapping.BeanWrapperowMapper">
<property name="targetType" value="com.shoppers.sales.job.model.Customer" />
</bean>
</property>
</bean>