Maven下载错误的Spring jar版本

时间:2015-06-29 15:23:40

标签: maven dependencies javabeans spring-integration

我一直试图找到一种方法来解决这个问题一段时间,但没有任何成功。我在bean 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:int="http://www.springframework.org/schema/integration"
   xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
   xsi:schemaLocation="http://www.springframework.org/schema/integration
    http://www.springframework.org/schema/integration/spring-integration.xsd
    http://www.springframework.org/schema/integration/jdbc
    http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security.xsd">



<beans profile="dev, local">
    <bean id="emailVerificationMessageStore" class="org.springframework.integration.store.SimpleMessageStore"/>
</beans>
<beans profile="production, staging">
    <int-jdbc:message-store id="emailVerificationMessageStore" data-source="dataSource" region="emailVerification"/>
</beans>

配置文件元素位于文件的末尾,如上所示。 当我部署到我的tomcat服务器时,我看到以下错误:

 Line 58 in XML document from URL [file:/var/lib/tomcat6/webapps/project/WEB-INF/classes/META-INF/spring/context.xml]
 is invalid; nested exception is org.xml.sax.SAXParseException; 
 lineNumber: 58; columnNumber: 33;
 cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans'.
 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"]}' is expected.

我运行mvn依赖:树看到maven正在下载正确的jar版本,似乎即使我已经在Pom.Xml中指定了最新版本,它正在下载3.0.0罐子:

 --- maven-dependency-plugin:2.8:tree (default-cli) @ services ---
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-aop/3.0.0.RC3/spring-aop-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-context/3.0.0.RC3/spring-context-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-asm/3.0.0.RC3/spring-asm-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-core/3.0.0.RC3/spring-core-3.0.0.RC3.jar
 Downloading: http://repo.maven.apache.org/maven2/org/springframework/spring-beans/3.0.0.RC3/spring-beans-3.0.0.RC3.ja

我如何强制maven下载更高版本的jar?

1 个答案:

答案 0 :(得分:0)

使用eclipse的Dependancy层次结构工具找到了答案,似乎导入Jersey jar包含Spring 3.0.0,因此覆盖了我的其他jar。

添加此功能解决了这个问题:

<dependency>
        <groupId>com.sun.jersey.contribs</groupId>
        <artifactId>jersey-spring</artifactId>
        <version>1.8</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
        </exclusions>
    </dependency>