简体   繁体   English

Eclipse导入在Java更新后无法解决

[英]Eclipse the import cannot be resolved after Java update

I have class that uses hibernate, I have included all required jars to classpath and class worked before Java updated itself. 我有使用休眠的类,我将所有必需的jar包含到类路径中,并且在Java更新自身之前可以使用类。 But now eclipse shows that it cannot resolve some hibernate imports. 但是现在eclipse显示它无法解决某些休眠导入。 What could be solution to this? 有什么解决方案?

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

Delete .m2/repository/org/hibernate/*, then in eclipse: Maven/update Project. 删除.m2 / repository / org / hibernate / *,然后在eclipse中:Maven / update Project。 It will download the dependencies again. 它将再次下载依赖项。 It worked for me! 它为我工作!

Did you try "Project > Clean ..."? 您是否尝试过“项目>清洁...”? What is the exact error message? 确切的错误消息是什么? After a Java update, you might need to update the path to the JDK: "Window > Preferences > Java > Installed JREs" Java更新后,您可能需要更新JDK的路径:“窗口>首选项> Java>已安装的JRE”

If you type (Ctrl + shift + t), or open the Type Explorer and type SessionFactory or Configuration does Eclipse find them? 如果键入(Ctrl + shift + t),或打开类型资源管理器并键入SessionFactory或Configuration,Eclipse是否会找到它们? If not, then for sure you have some problems in the .jar files. 如果不是,那么可以确定.jar文件中存在一些问题。 Try to delete and replace them. 尝试删除并替换它们。

By the way are you using a Mac or PC? 顺便问一下,您使用的是Mac还是PC?

I experienced a similar problem that got fixed when I used Grails Tools > Refresh Dependencies (Alt+G,R). 使用Grails工具>刷新依赖关系(Alt + G,R)时,我遇到了类似的问题,该问题已得到解决。 This was in SpringSource Tool Suite 2.7.1. 这是在SpringSource Tool Suite 2.7.1中。

I had to run that once to get the plugins to initialize correctly (after an import from SVN) and then a second time to get references to work. 我必须运行一次以使插件正确初始化(从SVN导入后),然后再次运行以获取引用。

even i was facing the same problem . 甚至我也面临着同样的问题。 every thing was working fine but all of a suden every jsp page started giving me error saying org.apache.jasper.JasperException: Unable to compile class for JSP: 一切正常,但是每个jsp页面突然出现异常,给我说org.apache.jasper.JasperException错误:无法为JSP编译类:

An error occurred at line: 1 in the generated java file The type org.hibernate.SessionFactory cannot be resolved. 在生成的Java文件中的第1行发生错误:无法解析类型org.hibernate.SessionFactory。 It is indirectly referenced from required .class files 从所需的.class文件间接引用它

An error occurred at line: 9 in the generated java file Only a type can be imported. 在生成的java文件中的第9行发生错误:只能导入类型。 org.hibernate.Query resolves to a package org.hibernate.Query解析为一个包

An error occurred at line: 11 in the generated java file Only a type can be imported. 在生成的java文件中的第11行发生错误:只能导入类型。 org.hibernate.Session resolves to a package org.hibernate.Session解析为一个包

An error occurred at line: 12 in the generated java file Only a type can be imported. 在生成的java文件中的第12行发生错误:只能导入类型。 org.hibernate.SessionFactory resolves to a package org.hibernate.SessionFactory解析为一个包

An error occurred at line: 13 in the generated java file Only a type can be imported. 在生成的java文件中的第13行发生错误:只能导入类型。 org.hibernate.cfg.Configuration resolves to a package org.hibernate.cfg.Configuration解析为一个包

to solve thi problem in eclipse i removed/deleted the server from eclipse and added my tomcat server back and every thing started working same as before ..... 为了解决日食方面的问题,我从日食中删除/删除了服务器,并添加了我的tomcat服务器,一切开始与以前一样.....

Thanks 谢谢

I faced this problem today.I think eclipse tell me that he want to resolve something but don't know what problem and how.And here it is: 我今天遇到了这个问题,我认为日食告诉我他想解决一些问题,但不知道什么问题以及如何解决,这是:

SessionFactory factory;
    try {
        factory = new Configuration().configure().buildSessionFactory();
    } catch (Throwable ex) { 
        System.err.println("Failed to create sessionFactory object." + ex);
        throw new ExceptionInInitializerError(ex); 
    }

Maby it helps.In my case it was exception handling. Maby可以提供帮助。在我的情况下,它是异常处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM