Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring版本会自动更改为3.0.5.RELEASE,尽管我已经指定了3.1.0_Java_Spring_Maven_Noclassdeffounderror - Fatal编程技术网

Java Spring版本会自动更改为3.0.5.RELEASE,尽管我已经指定了3.1.0

Java Spring版本会自动更改为3.0.5.RELEASE,尽管我已经指定了3.1.0,java,spring,maven,noclassdeffounderror,Java,Spring,Maven,Noclassdeffounderror,这是我项目的POM: <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/maven-v4_0_0.xsd"> <modelVersion>4.0

这是我项目的POM:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>learn.spring</groupId>
    <artifactId>someProject</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>
    <name>someProject</name>
    <url>http://maven.apache.org</url>
    <repositories>
        <repository>
            <id>maven2-repository.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
            <layout>default</layout>
        </repository>
    </repositories>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <org.springframework.version>3.1.0.RELEASE</org.springframework.version>
        <org.slf4j.version>1.5.10</org.slf4j.version>
        <org.slf4j.version>1.5.10</org.slf4j.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>oro</groupId>
            <artifactId>oro</artifactId>
            <version>2.0.8</version>
        </dependency>

        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.3.1</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>

        </dependency>




        <!-- Jersey + Spring -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>1.8</version>
        </dependency>


        <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-aop</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>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>4.7.0</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>1.7-beta-1</version>
        </dependency>

        <!-- Log4j Dependency -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <!-- Postgres dependency -->
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901.jdbc4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>20030825.184428</version>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>20030825.183949</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>20040616</version>
        </dependency>

        <!-- JSTL dependency -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Spring Web Support -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>

            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>someProject</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0-SNAPSHOT</version>
            </plugin>
        </plugins>
    </build>



</project>

EnvironmentCapable.class文件位于
spring-core-3.1.0.RELEASE.jar
中。我手动将jar添加到构建路径中,但仍然得到相同的异常。我正在使用Eclipse Indigo。请给出建议。

如果您在
jersey-spring-1.8.jar
中选中
pom.xml
,您将看到以下内容:

    <properties>
        <spring20-release-version>2.0.5</spring20-release-version>
        <spring25-release-version>[2.5.2,3)</spring25-release-version>
    </properties>

2.0.5
[2.5.2,3)
这意味着,jersey-spring-1.8将强制您使用最多3个spring版本。
我认为这就是问题所在。

如果您在
jersey-spring-1.8.jar
中检查
pom.xml
,您将看到这一点

    <properties>
        <spring20-release-version>2.0.5</spring20-release-version>
        <spring25-release-version>[2.5.2,3)</spring25-release-version>
    </properties>

2.0.5
[2.5.2,3)
这意味着,jersey-spring-1.8将强制您使用最多3个spring版本。 我认为这就是问题所在。

这个
${org.springframework.version}
是从哪里来的?它在POM文件中没有定义为属性,所以我猜这个属性来自一个依赖项,并接管了
3.1.RELEASE
(提示:查看jersey spring依赖项) 不要使用属性来定义版本!使用Maven的部分来控制隐式和显式版本! 我建议您在
${org.springframework.version}
的来源处使用提供的依赖范围
,它在POM文件中没有定义为属性,因此我猜测该属性来自一个依赖项,并接管
3.1.RELEASE
(提示:查看jersey spring依赖项) 不要使用属性来定义版本!使用Maven的部分来控制隐式和显式版本!
我建议您使用dependency scope
提供的

问题在于POM中的LDAP依赖关系。它将3.0.5版本集成到构建路径中。通过
mvn dependency:tree
,问题变得显而易见

 learn.spring:someProject:war:1.0
 +- junit:junit:jar:3.8.1:test (scope not updated to compile)
 +- oro:oro:jar:2.0.8:compile
 +- commons-validator:commons-validator:jar:1.3.1:compile
 |  +- commons-beanutils:commons-beanutils:jar:1.7.0:compile
 |  \- commons-digester:commons-digester:jar:1.6:compile
 +- org.springframework.ldap:spring-ldap-core:jar:1.3.1.RELEASE:compile
 |  +- commons-logging:commons-logging:jar:1.0.4:compile
 |  +- commons-lang:commons-lang:jar:2.5:compile
 |  +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
 |  +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
 |  \- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
 +- com.sun.jersey:jersey-server:jar:1.8:compile
 |  +- asm:asm:jar:3.1:compile
 |  \- com.sun.jersey:jersey-core:jar:1.8:compile
 +- com.sun.jersey:jersey-json:jar:1.8:compile
 |  +- org.codehaus.jettison:jettison:jar:1.1:compile
 |  |  \- stax:stax-api:jar:1.0.1:compile
 |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
 |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
 |  |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
 |  |     \- javax.activation:activation:jar:1.1:compile
 |  +- org.codehaus.jackson:jackson-core-asl:jar:1.7.1:compile
 |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.7.1:compile
 |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.7.1:compile
 |  \- org.codehaus.jackson:jackson-xc:jar:1.7.1:compile
 +- com.sun.jersey.contribs:jersey-spring:jar:1.8:compile
 +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
 +- net.sf.jasperreports:jasperreports:jar:4.7.0:compile
 |  +- com.lowagie:itext:jar:2.1.7:compile
 |  |  +- bouncycastle:bcmail-jdk14:jar:138:compile
 |  |  +- bouncycastle:bcprov-jdk14:jar:138:compile
 |  |  \- org.bouncycastle:bctsp-jdk14:jar:1.38:compile
 |  |     +- org.bouncycastle:bcprov-jdk14:jar:1.38:compile
 |  |     \- org.bouncycastle:bcmail-jdk14:jar:1.38:compile
 |  +- jfree:jcommon:jar:1.0.15:compile
 |  +- jfree:jfreechart:jar:1.0.12:compile
 |  +- xml-apis:xml-apis:jar:1.3.02:compile
 |  +- eclipse:jdtcore:jar:3.1.0:compile
 |  +- org.codehaus.castor:castor:jar:1.2:compile
 |  \- org.apache.poi:poi-ooxml:jar:3.7:compile
 |     +- org.apache.poi:poi:jar:3.7:compile
 |     +- org.apache.poi:poi-ooxml-schemas:jar:3.7:compile
 |     |  +- org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile
 |     |  \- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0:compile
 |     \- dom4j:dom4j:jar:1.6.1:compile
 +- org.codehaus.groovy:groovy-all:jar:1.7-beta-1:compile
 |  +- org.apache.ant:ant:jar:1.7.1:compile
 |  |  \- org.apache.ant:ant-launcher:jar:1.7.1:compile
 |  \- jline:jline:jar:0.9.94:compile
 +- org.slf4j:jcl-over-slf4j:jar:1.5.8:runtime
 +- org.slf4j:slf4j-api:jar:1.5.8:runtime
 +- org.slf4j:slf4j-log4j12:jar:1.5.8:runtime
 +- log4j:log4j:jar:1.2.14:compile
 +- postgresql:postgresql:jar:9.1-901.jdbc4:compile
 +- org.springframework:spring-jdbc:jar:3.1.0.RELEASE:compile
 +- commons-dbcp:commons-dbcp:jar:20030825.184428:compile
 +- commons-pool:commons-pool:jar:20030825.183949:compile
 +- commons-collections:commons-collections:jar:20040616:compile
 +- javax.servlet:jstl:jar:1.2:compile
 +- org.springframework:spring-web:jar:3.1.0.RELEASE:compile
 |  +- aopalliance:aopalliance:jar:1.0:compile
 |  \- org.springframework:spring-context:jar:3.1.0.RELEASE:compile
 |     \- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
 \- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
    \- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
正如上面所建议的那样,将
提供的
添加到LDAP依赖项工作正常。我在依赖项中添加了
排除
,这相当繁琐。:)


org.springframework.ldap
SpringLDAP核心
1.3.1.发布
org.springframework
春天
org.springframework
弹簧芯
org.springframework
春季aop
org.springframework
弹簧网
org.springframework
春豆
org.springframework
spring上下文
org.springframework
德克萨斯州春季

问题在于POM中的LDAP依赖关系。它将3.0.5版本集成到构建路径中。通过
mvn依赖关系:树
,问题变得显而易见

 learn.spring:someProject:war:1.0
 +- junit:junit:jar:3.8.1:test (scope not updated to compile)
 +- oro:oro:jar:2.0.8:compile
 +- commons-validator:commons-validator:jar:1.3.1:compile
 |  +- commons-beanutils:commons-beanutils:jar:1.7.0:compile
 |  \- commons-digester:commons-digester:jar:1.6:compile
 +- org.springframework.ldap:spring-ldap-core:jar:1.3.1.RELEASE:compile
 |  +- commons-logging:commons-logging:jar:1.0.4:compile
 |  +- commons-lang:commons-lang:jar:2.5:compile
 |  +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
 |  +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
 |  \- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
 +- com.sun.jersey:jersey-server:jar:1.8:compile
 |  +- asm:asm:jar:3.1:compile
 |  \- com.sun.jersey:jersey-core:jar:1.8:compile
 +- com.sun.jersey:jersey-json:jar:1.8:compile
 |  +- org.codehaus.jettison:jettison:jar:1.1:compile
 |  |  \- stax:stax-api:jar:1.0.1:compile
 |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
 |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
 |  |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
 |  |     \- javax.activation:activation:jar:1.1:compile
 |  +- org.codehaus.jackson:jackson-core-asl:jar:1.7.1:compile
 |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.7.1:compile
 |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.7.1:compile
 |  \- org.codehaus.jackson:jackson-xc:jar:1.7.1:compile
 +- com.sun.jersey.contribs:jersey-spring:jar:1.8:compile
 +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
 +- net.sf.jasperreports:jasperreports:jar:4.7.0:compile
 |  +- com.lowagie:itext:jar:2.1.7:compile
 |  |  +- bouncycastle:bcmail-jdk14:jar:138:compile
 |  |  +- bouncycastle:bcprov-jdk14:jar:138:compile
 |  |  \- org.bouncycastle:bctsp-jdk14:jar:1.38:compile
 |  |     +- org.bouncycastle:bcprov-jdk14:jar:1.38:compile
 |  |     \- org.bouncycastle:bcmail-jdk14:jar:1.38:compile
 |  +- jfree:jcommon:jar:1.0.15:compile
 |  +- jfree:jfreechart:jar:1.0.12:compile
 |  +- xml-apis:xml-apis:jar:1.3.02:compile
 |  +- eclipse:jdtcore:jar:3.1.0:compile
 |  +- org.codehaus.castor:castor:jar:1.2:compile
 |  \- org.apache.poi:poi-ooxml:jar:3.7:compile
 |     +- org.apache.poi:poi:jar:3.7:compile
 |     +- org.apache.poi:poi-ooxml-schemas:jar:3.7:compile
 |     |  +- org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile
 |     |  \- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0:compile
 |     \- dom4j:dom4j:jar:1.6.1:compile
 +- org.codehaus.groovy:groovy-all:jar:1.7-beta-1:compile
 |  +- org.apache.ant:ant:jar:1.7.1:compile
 |  |  \- org.apache.ant:ant-launcher:jar:1.7.1:compile
 |  \- jline:jline:jar:0.9.94:compile
 +- org.slf4j:jcl-over-slf4j:jar:1.5.8:runtime
 +- org.slf4j:slf4j-api:jar:1.5.8:runtime
 +- org.slf4j:slf4j-log4j12:jar:1.5.8:runtime
 +- log4j:log4j:jar:1.2.14:compile
 +- postgresql:postgresql:jar:9.1-901.jdbc4:compile
 +- org.springframework:spring-jdbc:jar:3.1.0.RELEASE:compile
 +- commons-dbcp:commons-dbcp:jar:20030825.184428:compile
 +- commons-pool:commons-pool:jar:20030825.183949:compile
 +- commons-collections:commons-collections:jar:20040616:compile
 +- javax.servlet:jstl:jar:1.2:compile
 +- org.springframework:spring-web:jar:3.1.0.RELEASE:compile
 |  +- aopalliance:aopalliance:jar:1.0:compile
 |  \- org.springframework:spring-context:jar:3.1.0.RELEASE:compile
 |     \- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
 \- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
    \- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
正如上面所建议的那样,将
提供的
添加到LDAP依赖项工作正常。我在依赖项中添加了
排除
,这相当繁琐。:)


org.springframework.ldap
SpringLDAP核心
1.3.1.发布
org.springframework
春天
org.springframework
弹簧芯
org.springframework
春季aop
org.springframework
弹簧网
org.springframework
春豆
org.springframework
spring上下文
org.springframework
德克萨斯州春季

当我复制/粘贴您的pom并运行dependency:tree时,唯一的Spring版本是3.1.0。您在哪里看到3.0.5 jar?@RyanStewart在我的eclipse构建文件夹中看到了它。如果使用Spring 3.1.0,则
NoClassDefFoundError
不会出现。当我复制/粘贴您的pom并运行dependency:tree时,唯一的Spring版本是3.1.0.你在哪里看到3.0.5 jar?@RyanStewart在我的eclipse构建文件夹中看到了它。如果使用了Spring 3.1.0,那么
NoClassDefFoundError
就不会出现。