简体   繁体   English

错误! java.lang.NoSuchMethodError:运行命令maven install时

[英]ERROR! java.lang.NoSuchMethodError: when running command maven install

I have the following error when I execute the command mvn install . 执行命令mvn install时出现以下错误。 I have seen few posts online related to my problem but I still could not resolve my issue. 我在网上看不到与我的问题有关的帖子,但仍然无法解决我的问题。 The error is: 错误是:

<<< ERROR! <<<错误! java.lang.NoSuchMethodError: org.springframework.beans.BeanUtils.instantiateClass(Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object; java.lang.NoSuchMethodError:org.springframework.beans.BeanUtils.instantiateClass(Ljava / lang / Class; Ljava / lang / Class;)Ljava / lang / Object; at org.springframework.test.context.ContextLoaderUtils.resolveContextLoader(ContextLoaderUtils.java:87) 在org.springframework.test.context.ContextLoaderUtils.resolveContextLoader(ContextLoaderUtils.java:87)

And here is my pom.xml file: 这是我的pom.xml文件:

   <!-- this file is generated with GWT webAppCreator -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mangroove.utils.MangrooveApp</groupId>
    <artifactId>MangrooveWeb</artifactId>
    <packaging>war</packaging>
    <version>0.0.0</version>
    <name>Mangroove appplication UI</name>
    <parent>
        <groupId>com.mangroove</groupId>
        <artifactId>mangroove-super-pom</artifactId>
        <version>0.0.0.11</version>
    </parent>
    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <!-- Version properties -->
        <gwtVersion>2.4.0</gwtVersion>
        <springVersion>3.1.1.RELEASE</springVersion>
       <mangroovedao.version>[0.0,1.0)</mangroovedao.version>
       <Project1.version>[1.20,1.21)</Project1.version>
        <Project2.version>1.0.0.98</Project2.version>
        <!-- Maven will save WAR file here -->
        <final.name>MangrooveUI</final.name>
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.mangroove.dao</groupId>
            <artifactId>MangrooveDao</artifactId>
            <version>${mangroovedao.version}</version>
        </dependency>
        <dependency>
            <groupId>com.mangroove.dao</groupId>
            <artifactId>MangrooveDao</artifactId>
            <version>${mangroovedao.version}</version>
            <classifier>sources</classifier>
            <scope>provided</scope>
        </dependency>
        <!-- Project1 dependency -->
        <dependency>
            <groupId>com.project1</groupId>
            <artifactId>Project1</artifactId>
            <version>${Project1.version}</version>
        </dependency>

        <!-- Project2 dependency -->
        <dependency>
            <groupId>com.project2</groupId>
            <artifactId>Project2</artifactId>
            <version>${Project2.version}</version>
        </dependency>
        <!-- GWT dependencies -->
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Testing/validation dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
            <scope>test</scope>
        </dependency>
        <!-- Spring dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${springVersion}</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>com.mangroove</groupId>
            <artifactId>xhtmlrenderer-core-renderer</artifactId>
            <version>[8.0.1,)</version>
        </dependency>
        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
        </dependency>
        <dependency>
            <groupId>jexcelapi</groupId>
            <artifactId>jxl</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk16</artifactId>
            <version>1.46</version>
        </dependency>
        <dependency>
            <groupId>org.jfree</groupId>
            <artifactId>jcommon</artifactId>
            <version>1.0.23</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes><exclude>MangrooveWeb.xml</exclude></excludes>
            </resource>
        </resources>
        <plugins>
            <!-- Copy static web files before executing gwt:run -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>exploded</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <webappDirectory>${webappDirectory}</webappDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.4.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <!-- <goal>test</goal> -->
                            <goal>generateAsync</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <runTarget>Main.html</runTarget>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I am not sure this task can solve 100% problem, but it is better: 我不确定此任务能否解决100%的问题,但更好的方法是:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${springVersion}</version>
    <scope>test</scope>
</dependency>

(add scope test ) (添加范围test

The error seems to be due to incompatible libraries being used. 该错误似乎是由于使用了不兼容的库。 The spring version you are using may not support Java 1.7 您使用的春季版本可能不支持Java 1.7

http://docs.spring.io/spring/docs/3.1.1.RELEASE/spring-framework-reference/html/new-in-3.0.html#new-in-3.0-intro http://docs.spring.io/spring/docs/3.1.1.RELEASE/spring-framework-reference/html/new-in-3.0.html#new-in-3.0-intro

Try either bumping up the spring version or downgrading the java version. 尝试提高春季版本或降级Java版本。 Also, make sure there are no libraries with 2 different versions being added implicitly causing the incompatibility. 另外,请确保没有隐式添加两个导致不兼容的版本的库。 If you are using an IDE like eclipse, try the maven plugin and see the versions of all the libraries it is resolving to. 如果您使用的是类似eclipse的IDE,请尝试使用maven插件,并查看其解析到的所有库的版本。 Few of the libraries you are using implicitly may download different version of a dependent library causing the conflict. 您隐式使用的库中,很少会下载导致冲突的依赖库的不同版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM