java.lang.NoSuchMethodError:org.hibernate.cfg.Environment.verifyProperties [英] java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties
问题描述
java.lang.NoSuchMethodError:org.hibernate.cfg.Environment.verifyProperties(Ljava / util / Map;)V
at org.hibernate.service.ServiceRegistryBuilder.buildServiceRegistry(ServiceRegistryBuilder.java:244)
使用hibernate版本:
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-c3p0< / artifactId>
< version> 4.1.1.Final< / version>
< type> jar< / type>
< /依赖关系>
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-entitymanager< / artifactId>
< version> 4.1.1.Final< / version>
< /依赖关系>
public class HibernateUtils {
private static final String DATABASE_HOST =host_to_db;
私有静态SessionFactory工厂;
private static ServiceRegistry serviceRegistry;
public static void init(){
Configuration config = getConfiguration();
config.configure();
serviceRegistry = new ServiceRegistryBuilder()。applySettings(
config.getProperties())。buildServiceRegistry();
config.setSessionFactoryObserver(new SessionFactoryObserver(){
$ b $ @Override
public void sessionFactoryCreated(SessionFactory factory){}
@Override
public void sessionFactoryClosed(SessionFactory factory){
ServiceRegistryBuilder.destroy(serviceRegistry);
}
});
factory = config.buildSessionFactory(serviceRegistry);
-core.jar版本中,Map版本仅在更新的版本中添加(可能在4.2.X左右),请检查您的Eclipse / Maven'Dependency Hierarchy'选项卡以分析版本冲突。
public static void verifyProperties(Map <?,?>> configurationValues)
我的问题只有在删除本地Hibernate Maven库时才解决,然后再次运行安装。
While trying to build the session factory I get this. Very little turns up in an Internet search. But it's got me dead-in-the-water for days now. Thanks.
java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V
at org.hibernate.service.ServiceRegistryBuilder.buildServiceRegistry(ServiceRegistryBuilder.java:244)
Using hibernate version:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.1.1.Final</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.1.Final</version>
</dependency>
public class HibernateUtils {
private static final String DATABASE_HOST = "host_to_db";
private static SessionFactory factory;
private static ServiceRegistry serviceRegistry;
public static void init() {
Configuration config = getConfiguration();
config.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(
config.getProperties()).buildServiceRegistry();
config.setSessionFactoryObserver(new SessionFactoryObserver() {
@Override
public void sessionFactoryCreated(SessionFactory factory) { }
@Override
public void sessionFactoryClosed(SessionFactory factory) {
ServiceRegistryBuilder.destroy(serviceRegistry);
}
});
factory = config.buildSessionFactory(serviceRegistry);
}
You have a conflict with hibernate-core.jar versions, the Map version was added only in later versions (around 4.2.X maybe?), check your Eclipse/Maven 'Dependency Hierarchy' tab to analyze version conflicts.
public static void verifyProperties(Map<?,?> configurationValues)
My problem was resolved only when I deleted my local Hibernate Maven repo and ran install again.
这篇关于java.lang.NoSuchMethodError:org.hibernate.cfg.Environment.verifyProperties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!