Hibernate中报错:ServiceRegistryBuilder cannot be resolved to a type
程序员文章站
2022-04-25 21:25:40
...
原因:下载的Hibernate版本过高。
Hibernate创建ServiceRegistryBuilder
ServiceRegistryBuilder srb=new ServiceRegistryBuilder();
在Hibernate5.0之前是没有问题的,但是如果在Hibernate5.0之后就会出问题,提示:
ServiceRegistryBuilder cannot be resolved to a type,而且不会提示你import 相应包。
原因是:Hibernate5.0之后废弃了ServiceRegistryBuilder,因此在你下载的hibernate-release-5.0.Fianl并不提供相应的包。
解决方案:
去官网下载Hibernate5.0之前的版本。
可尝试通过以下代码解决
ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(
cfg.getProperties()).getBootstrapServiceRegistry();
上一篇: 浅析SpringAop编程之切入点表达式
推荐阅读
-
JSP报错javax.servlet.jsp.JspException cannot be resolved to a type solution
-
JSP报错javax.servlet.jsp.JspException cannot be resolved to a type solution
-
hibernate报错:JoinColumn cannot be resolved to a type
-
Hibernate中报错:ServiceRegistryBuilder cannot be resolved to a type
-
MyEclipse报错:Multiple annotations found at this line: - String cannot be resolved to a type解决方法实测