从Batch File运行jar时,Cvc-elt.1找不到元素'beans'的声明

时间:2018-02-02 09:29:41

标签: java spring eclipse maven batch-file

我有一个包结构的maven项目如下:

enter image description here

的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</groupId>
  <artifactId>WMR-API-AR2</artifactId>
  <version>0.0.1</version>
  <name>WMR-API-AR2</name>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <springframework.version>4.1.2.RELEASE</springframework.version>
    <oracle.connector.version>11.2.0</oracle.connector.version>
  </properties>
  <dependencies>
    <!-- Spring Dependencies -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${springframework.version}</version>
    </dependency>   
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${springframework.version}</version>
    </dependency>   
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <!-- Oracle Dependencies -->
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>${oracle.connector.version}</version>
    </dependency>   
    <!-- Apache POI Dependencies -->
    <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi</artifactId>
         <version>3.17</version>
     </dependency>       
     <dependency>
         <groupId>org.apache.poi</groupId>
         <artifactId>poi-ooxml</artifactId>
         <version>3.17</version>
     </dependency>
  </dependencies>
  <build>
    <plugins>
        <plugin>
            <!-- Build an executable JAR -->
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <outputDirectory>lib</outputDirectory>
                <descriptorRefs>
                           <descriptorRef>jar-with-dependencies</descriptorRef>
                   </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>com.Application</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                   <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
               </executions>
        </plugin>
    </plugins>  
  </build>
</project>

的applicationContext.xml

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

    <bean id="mailProperties"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
        <property name="location" value="file:///C:/Users/abhishek.roy/eclipse-workspace/WMR-API-AR2/config/jdbc.properties" />
    </bean>

    <bean id="datasourcedev04" class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
        <property name="driverClassName" value="${driver_class_name}"></property>
        <property name="url" value="${dev4.url}"></property>
        <property name="username" value="${dev4.username}"></property>
        <property name="password" value="${dev4.password}"></property>
    </bean>

    <bean id="datasourcelocal" class="org.springframework.jdbc.datasource.DriverManagerDataSource">  
        <property name="driverClassName" value="${driver_class_name}"></property>
        <property name="url" value="${local.url}"></property>
        <property name="username" value="${local.username}"></property>
        <property name="password" value="${local.password}"></property>
    </bean>

</beans>

我们的想法是将项目构建为可执行文件 .jar (存在于lib文件夹中)并从 .batch 文件运行它(出现在bin文件夹中)

在Eclipse中执行代码时,代码运行良好。但是,当我尝试从.batch文件运行它时,遇到以下异常:

enter image description here 我无法弄清楚这个例外背后的原因。任何帮助将不胜感激。

0 个答案:

没有答案