java.lang.NoSuchMethodError:org.springframework.util.ClassUtils.forName(Ljava [英] java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.forName(Ljava

查看:1105
本文介绍了java.lang.NoSuchMethodError:org.springframework.util.ClassUtils.forName(Ljava的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用非常简单的代码返回XML

I use very simple code that returns XML

RestTemplate restTemplate = new RestTemplate();

Source oResponse = restTemplate.postForObject(url, entity, Source.class,
            vars);

XPathOperations xpathTemplate = new Jaxp13XPathTemplate();
String address = xpathTemplate.evaluateAsString("//status", oResponse);

但是,出现以下错误

java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;
at org.springframework.xml.JaxpVersion.<clinit>(JaxpVersion.java:51)
at org.springframework.xml.transform.TraxUtils.isStaxSource(TraxUtils.java:70)
at org.springframework.xml.xpath.Jaxp13XPathTemplate.evaluate(Jaxp13XPathTemplate.java:131)
at org.springframework.xml.xpath.Jaxp13XPathTemplate.evaluateAsString(Jaxp13XPathTemplate.java:91)

请帮助. 谢谢, 弗拉基米尔

Please help. Thanks, Vladimir

推荐答案

运行时出现NoSuchMethodError表示您使用的库版本与针对代码构建的库版本不同.

A NoSuchMethodError at runtime indicates that you are using a different version of a library than the version the code was built against.

在您的情况下,Spring是元凶.在运行时检查类路径上的内容,并确保以下内容:

In your case, Spring is the culprit. Check what is on the classpath at runtime and ensure the following:

  • 版本与编译时jar相同
  • 如果有多个版本,请删除不需要的版本

查看 http://docs.spring .io/spring/docs/3.2.0.M1/api/org/springframework/util/ClassUtils.html ,看来从Spring 3开始不推荐使用ClassUtils.forName(String).您已经针对具有此方法的版本构建了代码,但是正在使用已删除该方法的版本运行代码.

Looking at http://docs.spring.io/spring/docs/3.2.0.M1/api/org/springframework/util/ClassUtils.html, it would appear that ClassUtils.forName(String) is deprecated as of Spring 3. My guess would be you have built your code against a version which had this method but are running it with a version where the method has been removed.

ClassUtils类包含在spring-core jar中,因此我将确保在编译和运行时使用相同版本的jar.

The ClassUtils class is contained within the spring-core jar so I would ensure the same version of this jar is used at both compile and run time.

这篇关于java.lang.NoSuchMethodError:org.springframework.util.ClassUtils.forName(Ljava的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆