Error: java.lang.NoSuchMethodError: org/springframework/asm/ClassVisitor.<init>(I)V

跟風遠走 提交于 2019-12-20 06:15:22

问题


I have these two dependencies in my POM which are i think creating this issue but i have tried many different ways and updated versions but nothing worked for me. Can someone please help. POM.XML

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


回答1:


Solution to your Question

  1. It seems there is a JAR conflict while managing your dependencies.
  2. In Spring 4.2.0, the ClassVisitor class have been included in Spring-core-4.2.0.RELEASE.jar, Please find the below image. Hence there is no need to include spring-asm-3.1.3.RELEASE.jar which I have found in your dependencies.
  3. It is always recommended to use Bill of Materials when you are using Spring 3.2.X and above versions.
  4. Please remove the CGLIB Proxy from dependency, as it is no longer needed when you are using Spring 3.2.X version and above. Please refer the spring-framework documentation for this.
  5. Finally your POM should be like this below. Humbly requesting you to ignore the hibernate and slf4j dependencies.

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


来源:https://stackoverflow.com/questions/35728400/error-java-lang-nosuchmethoderror-org-springframework-asm-classvisitor-init

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!