从所需的.class文件中间接引用 [英] Indirectly referenced from required .class files

查看:604
本文介绍了从所需的.class文件中间接引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在STS中遇到以下错误:

I'm getting below error in STS:


无法解析org.springframework.core.env.EnvironmentCapable类型。它是从所需的.class文件间接引用的。

The type org.springframework.core.env.EnvironmentCapable cannot be resolved. It is indirectly referenced from required .class files


推荐答案

这听起来像是一个传递依赖问题。这意味着您的代码依赖于jar或库来执行某些操作 - 显然,您依赖于Spring框架代码。那么,所有Spring代码也依赖于库和jar。

This sounds like a transitive dependency issue. What this means is that your code relies on a jar or library to do something - evidently, you depend on Spring framework code. Well, all that Spring code also depends on libraries and jars.

最有可能的是,您需要将corerctly版本化的 org.springframework.core jar添加到类路径中,以便当您尝试构建项目时,可以找到 EnvironmentCapable 类。

Most likely, you need to add the corerctly versioned org.springframework.core jar to your classpath so that the EnvironmentCapable class can be found when your IDE attempts to build your project.

这也可能是一个jar冲突问题,尽管听起来不太可能。当应用程序遇到jar冲突(也称为dll hell)时,编译器会查找具有相同完全限定名称的多个jar和类。例如,假设您将Spring添加到类路径以及整个Tomcat服务器库。那么,这两个罐子可能包含完全相同的命名类,可能是相同的版本,也许是不同的版本。但无论如何,当编译器查找 EnvironmentCapable 类时,它会找到两个(在这个设计的例子中) - 一个在Spring jar中,一个在Tomcat jar中。好吧,它不知道选择哪一个,所以它会抛出一个 ClassDefNotFoundException ,这会/可能表现为你遇到的错误。

This might also be a jar collision issue as well, although that sounds less likely. When an application experiences jar collision (also known as "dll hell"), the compiler is finding multiple jars and classes with the same fully-qualified name. For example, let's say you added Spring to your classpath, along with the entire Tomcat server library. Well, those two jars may contain the same exact named classes, maybe the same version, maybe different versions. But either way, when the compiler looks for that EnvironmentCapable class, it finds two (in this contrived example) - one in the Spring jar and one in the Tomcat jar. Well, it doesn't know which one to choose, and so it throws a ClassDefNotFoundException, which would/could manifest itself as the error you experienced.

这篇关于从所需的.class文件中间接引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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