Eclipse 错误:“无法解析导入 XXX" [英] Eclipse error: "The import XXX cannot be resolved"

查看:44
本文介绍了Eclipse 错误:“无法解析导入 XXX"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Eclipse 中使用 Hibernate.我正在创建一个新的简单项目,并且我也通过 CVS 下载了一个同事项目.两者都不起作用,而在我同事的 Eclipse 上则起作用.问题是,对于 Hibernate 类的每次导入,Eclipse 都会说:

I'm trying to work with Hibernate in Eclipse. I'm creating a new simple project and I've downloaded a collegue project too, via CVS. Both don't work, while on my collegue's Eclipse do. The problem is that, for each import of an Hibernate class, Eclipse says:

The import org.hibernate cannot be resolved

但是所有 Hibernate jars 都在构建路径中,即:

But all Hibernate jars are in the build path, that is:

antlr-2.7.6.jar
cglib-2.2.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
hibernate3.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
javassist-3.12.0.GA.jar
jta-1.1.jar
slf4j-api-1.6.1.jar

推荐答案

显然在某些情况下存在有效问题,但是 Eclipse 有时会无缘无故地抛出此错误.这仍然是(在 v 2020-09 中)一个旧的(2010 年)Eclipse 错误,可以通过对项目设置进行微不足道的更改来解决.

Obviously there are cases where there is a valid issue however Eclipse throws this error for no good reason sometimes. This is still (in v 2020-09) an old (2010) Eclipse bug that can be resolved by making a negligible change to the project settings.

touch .classpath

解决问题,或转到项目>属性 >Java构建路径>订购和出口 >进行无意义的订单更改 >申请.改回顺序不会回归问题.

solves the issue, or go to Project > Properties > Java Build Path > Order and Export > make a meaningless order change > Apply. Changing the order back does not regress to the problem.

这篇关于Eclipse 错误:“无法解析导入 XXX"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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