• 【报错】项目启动部署时报错:java.lang.NoSuchMethodError


    报错:

    =====================================================================================================

    项目启动部署报错:

    java.lang.NoSuchMethodError: org.springframework.util.ReflectionUtils.doWithLocalFields(Ljava/lang/Class;Lorg/springframework/util/ReflectionUtils$FieldCallback;)V
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:418)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:397)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:333)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:872)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:495)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

    只粘贴了部分错误在这里。

    错误具体是什么,不重要,关键是这类型问题

    java.lang.NoSuchMethodError

    怎么解决才是最关键的问题!!!

    分析:

    ==========================================================================================

    海量的帖子/文章中都声明了这个问题的根源所在。

    不是调用这个类,类中方法不存在;

    就是这个方法在多个类中都有;

    翻来覆去就是架包不匹配啦,版本不一致啦,冲突啦,啦啦啦乱七八糟的。好吧,怎么解决呢?

    解决:

    ==========================================================================================

    ①不管你用的什么IDE,无论ecplise还是myecplise又或者idea。在解决这个问题之前,你需要懂得一件事,就是会在项目启动前,配置JVM参数。

    参考:http://www.cnblogs.com/sxdcgaq8080/p/8022096.html一看就懂了。

     

    ②添加一个VM参数

    -XX:+TraceClassLoading

    ③保存后重启项目

    ④发现报错和上面是哪个架包出现了问题

    那么去检查

        1》是不是这个架包没有下载下来

        2》是不是这个架包中这个类下没有这个方法

        3》是否要更换架包版本来解决这个问题

        4》是否别的架包也有这个相同类的相同方法,导致找不到本方法

    按照这样的思路解决问题即可。

    ⑤仅对应本次截图出现的问题,解决方法

      在Stack Overflow找到相同的问题,由于对spring源码并非特别熟悉,只是提出在4.2以后上面报错的方法就被提到了spring-core架包中而不是在orm架包中,所以,需要将spring-orm架包的版本降低到<4.2以下。即可解决问题!!

      

      我更改spring版本就是统一更改的,完整的pom.xml文件在最后给出。

    =========================================================================================

    spring整合activeMQ的完整pom.xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <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>com.sxd</groupId>
        <artifactId>springDemo</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>war</packaging>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <spring.version>4.1.9.RELEASE</spring.version>
            <hibernate.version>4.3.8.Final</hibernate.version>
            <jackson.version>2.5.0</jackson.version>
    
        </properties>
    
        <dependencies>
    
            <!--ActiveMQ-->
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-all</artifactId>
                <version>5.12.1</version>
            </dependency>
            <!-- junit -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
    
            <!-- spring -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jms</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
                <scope>test</scope>
            </dependency>
    
            <!-- 使用SpringMVC需配置 -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <!-- spring  cglib 代理 -->
            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>2.2.2</version>
            </dependency>
            <!-- 关系型数据库整合时需配置 如hibernate jpa等 -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <!-- hibernate -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-ehcache</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
    
            <!-- 二级缓存ehcache -->
            <dependency>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
                <version>2.9.0</version>
            </dependency>
    
            <!-- log4j -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
    
            <!-- mysql连接 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.34</version>
            </dependency>
    
            <!-- c3p0数据源 -->
            <dependency>
                <groupId>com.mchange</groupId>
                <artifactId>c3p0</artifactId>
                <version>0.9.5-pre10</version>
            </dependency>
    
            <!-- json -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.3</version>
            </dependency>
    
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${jackson.version}</version>
            </dependency>
    
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${jackson.version}</version>
            </dependency>
    
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>
    
            <!-- aop -->
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>1.8.4</version>
            </dependency>
    
            <!-- servlet -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>3.0-alpha-1</version>
                <scope>provided</scope>
            </dependency>
    
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>
    
        </dependencies>
    
    </project>
    View Code
  • 相关阅读:
    ios in-house 公布整个过程(startssl认证)
    各种图的创建以及广度,深度优先遍历(临接矩阵存储)
    SWTBOK測试实践系列(1) -- 測试在项眼下期的评审投入划算吗?
    欢天喜地迎国庆,国产开源编程语言 RPP 1.87 公布!
    正确地在QML应用中使用fontsize
    iOS 9音频应用播放音频之第一个ios9音频实例
    iOS 9音频应用播放音频之ios9音频基本功能
    iOS 9音频应用开发基础教程
    MAC OS 10.11.1虚拟机免费下载已安装Xcode7图片后有下载地址
    检验Xcode是否被改动过的简单方法,不妨试试!!!
  • 原文地址:https://www.cnblogs.com/sxdcgaq8080/p/8022121.html
Copyright © 2020-2023  润新知