分类: Java
2011-05-02 22:35:05
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at com.jnhc.util.Util.getList(Util.java:34)
at com.jnhc.util.Util.main(Util.java:49)
对于此问题的出现,我遇见过两种情况:
1.hibernate.cfg.xml中,
解决方法:添加
2.在使用配置文件的时候,出现了一下的错误
Configuration config=new Configuration();
SessionFactory factory=config.buildSessionFactory();
而正确的方法是:SessionFactory factory=config.configure().buildSessionFactory();
当然,网上也有该问题出现的其他原因,我暂时还没遇到,可能你遇到的情况和我相同,在此将自己的问题和经验总结一下,希望能给大家带来帮助。