我如何在可执行jar中编译spring批处理项目?

时间:2015-11-10 23:38:32

标签: java eclipse maven spring-batch executable-jar

我有一个eclipse项目,这在eclipse中正确运行但是当我导出到可执行jar时不工作显示下一个异常:

 2015-11-10 15:30:35 INFO  DefaultListableBeanFactory:663 - Overriding bean definition for bean 'transactionManager': replacing [Generic bean: class [org.springframework.batch.support.transaction.ResourcelessTransactionManager]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [context.xml]] with [Generic bean: class [org.springframework.batch.support.transaction.ResourcelessTransactionManager]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [database.xml]]
 Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/batch]
 Offending resource: class path resource [job.xml]

无法找到XML架构命名空间http://www.springframework.org/schema/batch的Spring NamespaceHandler,但这只是在eclipse中编译jar时才能正常工作。

这是我的job.xml:

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/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"    
          xsi:schemaLocation="       
          http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        ">

    <import resource="context.xml" />
    <import resource="database.xml" />

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location"><value>application.properties</value></property>
    </bean>

    <bean id="irXmlRegenerate" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step">
        <property name="dataSource" ref="dataBaseSource" />
        <property name="sql">
            <value>
                SELECT * FROM Units
            </value>
        </property>
        <property name="rowMapper">
            <bean class="beans.UnitRowMapper" />
        </property>
    </bean>     

     <bean id="iwXmlRegenerate" class="org.springframework.batch.item.xml.StaxEventItemWriter" scope="step">
         <property name="resource" value="file:${Main.localDirectory}Regen\\#{jobParameters[RegenFileName]}" />
         <property name="marshaller" ref="UnitMarshaller" />
         <property name="rootTagName" value="UNITS" />
     </bean>     

     <bean id="UnitMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
         <property name="autodetectAnnotations" value="true"/>
     </bean>     

    <batch:job id="RegenTasks">
        <batch:step id="REGENERATE_FILE"> 
            <batch:tasklet>
                <batch:chunk reader="irXmlRegenerate" processor="ipXmlRviUnit" writer="iwXmlRegenerate" commit-interval="1" />
            </batch:tasklet>
        </batch:step>
    </batch:job>
 </beans>

我使用&lt;批次:工作&gt;相反&lt;工作&gt;这就是问题?如果我删除它时如何使用标记作业启动此异常:

 Line 615 in XML document from class path resource [job.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 615; columnNumber: 22; cvc-complex-type.2.4.a: Invalid content was found starting with element 'job'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.

0 个答案:

没有答案