2016-03-01 48 views
0

我在我的POM中有這兩個依賴關係,這是我認爲造成這個問題的原因,但我嘗試了很多不同的方法和更新版本,但沒有爲我工作。有人可以請幫助。 的pom.xml錯誤:java.lang.NoSuchMethodError:org/springframework/asm/ClassVisitor。 <init>(I)V

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>4.2.0.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>cglib</groupId> 
     <artifactId>cglib</artifactId> 
     <version>2.2</version> 
    </dependency>  

enter image description here

+0

你有完整的堆棧跟蹤和你的源代碼(的提取液是足夠了)? – superbob

+0

看起來像你有同樣的問題 http://stackoverflow.com/questions/2432471/error-java-lang-nosuchmethoderror-org-objectweb-asm-classwriter-initiv –

回答

1

解決你的問題

  1. 似乎有同時管理您的依賴關係的JAR衝突。
  2. 在Spring 4.2.0中,ClassVisitor類已包含在Spring-core-4.2.0.RELEASE.jar中,請查找下圖。因此,不需要在你的依賴項中包含spring-asm-3.1.3.RELEASE.jar。 ClassVisitor
  3. 當您使用Spring 3.2.X及更高版本時,始終建議使用Bill of Materials
  4. 請刪除CGLIB代理從依賴關係,因爲當您使用Spring 3.2.X version及以上版本時不再需要它。請參閱spring-framework文檔。
  5. 最後你的POM應該如下圖所示。虛心請求你忽略hibernate和slf4j的依賴關係。

              <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/xsd/maven-4.0.0.xsd"> 
                  <modelVersion>4.0.0</modelVersion> 
                  <groupId>org.springframework.samples</groupId> 
                  <artifactId>simpleSpring</artifactId> 
                  <version>0.0.1-SNAPSHOT</version> 
    
                  <properties> 
    
                   <!-- Generic properties --> 
                   <java.version>1.8</java.version> 
                   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
                   <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    
                   <!-- Spring --> 
                   <spring-framework.version>4.2.0.RELEASE</spring-framework.version> 
    
                   <!-- Hibernate/JPA --> 
                   <hibernate.version>4.2.1.Final</hibernate.version> 
    
                   <!-- Logging --> 
                   <logback.version>1.0.13</logback.version> 
                   <slf4j.version>1.7.5</slf4j.version> 
    
                   <!-- Test --> 
                   <junit.version>4.11</junit.version> 
    
                  </properties> 
                  <dependencies> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-aop</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-aspects</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-beans</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-context</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-context-support</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-core</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-expression</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-instrument</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-instrument-tomcat</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-jdbc</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-jms</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-messaging</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-orm</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-oxm</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-test</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-tx</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-web</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-webmvc</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-webmvc-portlet</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
                   <dependency> 
                   <groupId>org.springframework</groupId> 
                   <artifactId>spring-websocket</artifactId> 
                   <version>4.2.0.RELEASE</version> 
                   </dependency> 
    
    
                   <!-- Spring and Transactions --> 
                   <dependency> 
                    <groupId>org.springframework</groupId> 
                    <artifactId>spring-context</artifactId> 
                    <version>${spring-framework.version}</version> 
                   </dependency> 
                   <dependency> 
                    <groupId>org.springframework</groupId> 
                    <artifactId>spring-tx</artifactId> 
                    <version>${spring-framework.version}</version> 
                   </dependency> 
    
                   <!-- Logging with SLF4J & LogBack --> 
                   <dependency> 
                    <groupId>org.slf4j</groupId> 
                    <artifactId>slf4j-api</artifactId> 
                    <version>${slf4j.version}</version> 
                    <scope>compile</scope> 
                   </dependency> 
                   <dependency> 
                    <groupId>ch.qos.logback</groupId> 
                    <artifactId>logback-classic</artifactId> 
                    <version>${logback.version}</version> 
                    <scope>runtime</scope> 
                   </dependency> 
    
                   <!-- Hibernate --> 
                   <dependency> 
                    <groupId>org.hibernate</groupId> 
                    <artifactId>hibernate-entitymanager</artifactId> 
                    <version>${hibernate.version}</version> 
                   </dependency> 
    
    
                   <!-- Test Artifacts --> 
                   <dependency> 
                    <groupId>org.springframework</groupId> 
                    <artifactId>spring-test</artifactId> 
                    <version>${spring-framework.version}</version> 
                    <scope>test</scope> 
                   </dependency> 
                   <dependency> 
                    <groupId>junit</groupId> 
                    <artifactId>junit</artifactId> 
                    <version>${junit.version}</version> 
                    <scope>test</scope> 
                   </dependency> 
    
                  </dependencies> 
                 </project> 
    
相關問題