at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1287)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1309)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at com.hibernate.DemoHibernateTest.main(DemoHibernateTest.java:15)
解决:1 在Create a Java project时,一定要选Project layout中的Create separate source and output foldedrs 解决找不到hibernate.cfg.xml
2 在src下在创建log4j.properties 解决log4j:WARN
内容为:
log4j.rootLogger=debug,A1,R
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-ddHH:mm:ss}[%c]-[%p]%m-(:%L)%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=D:/workspace/DemoHibernate/HibernateDemoLog.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%-d{yyyy-MM-ddHH:mm:ss}[%c]-[%p]%m-(:%L)%n
修改DemoHibernateTest.java如下:
publicclass DemoHibernateTest {