SAXParseException:无法读取架构文档“ http://www.springframework.org/schema/context/spring-context.xsd”

时间:2019-05-23 13:48:55

标签: xml spring maven jms spring-batch

我开发了一个Spring批处理应用程序,可以用Java主类运行它,但是当我尝试用命令行运行它时,出现以下错误。 SAWParseException:无法读取架构文档“ http://www.springframework.org/schema/context/spring-context.xsd

我正在使用Spring 3.2.6.RELEASE和Spring批处理2.2.5.RELEASE

POM XML文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.app.poc.tool.purgeJms</groupId>
   <artifactId>purgeJmsQueue</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <properties>
      <java.version>1.7</java.version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <spring.version>3.2.6.RELEASE</spring.version>
   </properties>
   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
               <execution>
                  <goals>
                     <goal>shade</goal>
                  </goals>
                  <configuration>
                     <shadedArtifactAttached>true</shadedArtifactAttached>
                     <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                           <mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass>
                        </transformer>
                     </transformers>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
               <source>${java.version}</source>
               <target>${java.version}</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
   <dependencies>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-beans</artifactId>
         <version>${spring.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
         <version>${spring.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-aop</artifactId>
         <version>${spring.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-aspects</artifactId>
         <version>${spring.version}</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-tx</artifactId>
         <version>${spring.version}</version>
      </dependency>
      <dependency>
         <groupId>com.oracle.weblogic</groupId>
         <artifactId>thinclient</artifactId>
         <version>3</version>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
         <version>${spring.version}</version>
      </dependency>
      <!-- SPRING BATCH -->
      <dependency>
         <groupId>org.springframework.batch</groupId>
         <artifactId>spring-batch-core</artifactId>
         <version>2.2.5.RELEASE</version>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>org.springframework.batch</groupId>
         <artifactId>spring-batch-infrastructure</artifactId>
         <version>2.2.5.RELEASE</version>
      </dependency>
      <dependency>
         <groupId>org.springframework.batch</groupId>
         <artifactId>spring-batch-test</artifactId>
         <version>2.2.5.RELEASE</version>
      </dependency>
      <!-- JMS -->
      <dependency>
         <groupId>javax.jms</groupId>
         <artifactId>jms-api</artifactId>
         <version>1.1</version>
         <scope>provided</scope>
      </dependency>
      <!-- TEST -->
      <!-- JMS -->
      <dependency>
         <groupId>com.mockrunner</groupId>
         <artifactId>mockrunner-jms</artifactId>
         <version>1.0.0</version>
      </dependency>
      <dependency>
         <groupId>joda-time</groupId>
         <artifactId>joda-time</artifactId>
         <version>2.3</version>
      </dependency>
   </dependencies>
</project>

Spring beans XML文件:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:c="http://www.springframework.org/schema/c"
    xmlns:batch="http://www.springframework.org/schema/batch" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd      
        ">

        <context:property-placeholder location="classpath*:pocInfo.properties"/>
        <context:component-scan base-package="com.app.pc.sa.cnf.batch.purgequeue" />
        <bean id="purgeQueueServiceImpl" class="com.app.pc.sa.cnf.batch.purgequeue.PurgeQueueServiceImpl" scope="step">
          <property name="jndiFactory" value="${JNDI_FACTORY}"></property>
          <property name="connectionFactory" value="${CONNECTION_FACTORY}"></property>
          <property name="url" value="${url}"></property>
          <property name="jmsErrorQueue" value="${queueRetrieve}"> </property>

        </bean>
     <!-- Job Repository: used to persist the state of the batch job -->
    <bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>

    <!-- Job Launcher: creates the job and the job state before launching it -->
    <bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
        <property name="jobRepository" ref="jobRepository" />
    </bean>
       <bean id="jobRepository"
          class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"
          p:transactionManager-ref="transactionManager"
          p:isolationLevelForCreate="ISOLATION_DEFAULT" />

    <bean id="purgeQueueTasklet"
        class="com.app.pc.sa.cnf.batch.purgequeue.PurgeQueueTasklet" />

    <batch:job job-repository="jobRepository"  id="POC-SA-NF-JOB-UC-REF-088">
        <batch:step id="purgeStep">
            <batch:tasklet 
                ref="purgeQueueTasklet" >
            </batch:tasklet>
        </batch:step>
    </batch:job>
</beans>

运行批处理的命令

java -cp purgeJmsQueue-0.0.1-SNAPSHOT-shaded.jar;lib/* org.springframework.batch.core.launch.support.CommandLineJobRunner classpath:/config/application-context.xml jobId

enter image description here

0 个答案:

没有答案