我在applicationContext.xml中收到此错误以进行批处理 applicationContext如下:
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns:batch='http://www.springframework.org/schema/batch'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:context='http://www.springframework.org/schema/context'
xmlns:tx='http://www.springframework.org/schema/tx'
xmlns='http://www.springframework.org/schema/beans'
xsi:schemaLocation='http://www.springframework.org/schema/batch
http://www.springframework.org/schema/spring-batch.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd'>
<import resource="datasource-tx-jpa.xml" />
<!-- we can use annotations -->
<context:annotation-config />
<!-- package to look for annotated classes -->
<context:component-scan base-package='com.anirban.batch' />
<!-- we will manage transactions with annotations -->
<tx:annotation-driven />
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="databaseType" value="oracle" />
<property name="dataSource" ref="myDataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="isolationLevelForCreate" value="ISOLATION_DEFAULT" />
</bean>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<!-- XML Marshaller -->
<bean id="matchMarshaller" class="org.springframework.oxm.castor.CastorMarshaller">
<property name="mappingLocation" value="oxm-mapping.xml" />
</bean>
<!-- Batch job: Contact import -->
<batch:job id="importContactJob">
<batch:step id="readWriteStep">
<batch:tasklet transactionManager="transactionManager">
<batch:chunk reader="contactItemReader" processor="contactItemProcessor"
writer="contactItemWriter" commit-interval="4" />
</batch:tasklet>
</batch:step>
<batch:listners>
<batch:listner ref="importContactJoblistener" />
</batch:listners>
</batch:job>
<bean id="contactItemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
<property name="resource" value="file:///#{jobParameters['contact.xml']" />
<property name="fragmentRootElementName" value="person" />
<property name="unMarshaller" ref="batchMarshaller" />
</bean>
<bean id="contactItemWriter"
class="org.springframework.batch.item.adapter.ItemWriterAdapter">
<property name="targetObject" value="PersonDao" />
<property name="targetMethod" value="save" />
</bean>
<bean id="personDao" class="com.anirban.batch.dao.impl.PersonDaoImpl" />
<!-- <property name="sessionFactory" ref="mySessionFactory"/> </bean> -->
<bean id="log4jInitialization"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.springframework.util.Log4jConfigurer" />
<property name="targetMethod" value="initLogging" />
<property name="arguments">
<list>
<value>log4j.properties</value>
</list>
</property>
</bean>
</beans>
我收到
的以下标记错误此行找到多个注释: - 开始元素标记 - cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素的声明 '批次:工作'。
当我试图跑步时,它会抛出异常:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 46 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 46; columnNumber: 35; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'batch:job'.
和
Failed to read schema document 'http://www.springframework.org/schema/spring-batch.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
POM依赖关系:
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>${spring-batch.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-infrastructure</artifactId>
<version>${spring-batch.version}</version>
</dependency>
Maven依赖项中可用的批处理jar 1. spring-batch-core-2.2.0.RELEASE.jar 2. spring-batch-infrastructure-2.2.0.RELEASE.jar
有人可以帮忙吗?