簡體   English   中英

錯誤! java.lang.NoSuchMethodError:運行命令maven install時

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

執行命令mvn install時出現以下錯誤。 我在網上看不到與我的問題有關的帖子,但仍然無法解決我的問題。 錯誤是:

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

這是我的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>

我不確定此任務能否解決100%的問題,但更好的方法是:

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

(添加范圍test

該錯誤似乎是由於使用了不兼容的庫。 您使用的春季版本可能不支持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

嘗試提高春季版本或降級Java版本。 另外,請確保沒有隱式添加兩個導致不兼容的版本的庫。 如果您使用的是類似eclipse的IDE,請嘗試使用maven插件,並查看其解析到的所有庫的版本。 您隱式使用的庫中,很少會下載導致沖突的依賴庫的不同版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM