执行命令mvn install
时出现以下错误。我在网上看到很少与我的问题相关的帖子,但我仍然无法解决我的问题。错误是:
<<<错误! java.lang.NoSuchMethodError: org.springframework.beans.BeanUtils.instantiateClass(Ljava /郎/类; Ljava /郎/类;)Ljava /郎/对象; 在 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>
答案 0 :(得分:0)
我不确定此任务可以解决100%的问题,但它更好:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springVersion}</version>
<scope>test</scope>
</dependency>
(添加范围test
)
答案 1 :(得分:0)
错误似乎是由于使用了不兼容的库。您使用的spring版本可能不支持Java 1.7
尝试升级弹簧版本或降级java版本。此外,请确保没有隐式添加2个不同版本的库导致不兼容。如果您使用的是像eclipse这样的IDE,请尝试使用maven插件并查看它要解析的所有库的版本。您隐式使用的库很少会下载导致冲突的不同版本的从属库。