log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.HibernateException: JDBC Driver class not found: com.mysql.jdbc.Driver
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:66)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2090)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2086)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1311)
at com.hibtest4.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:32)
at com.hibtest4.dao.BaseHibernateDAO.add(BaseHibernateDAO.java:17)
at com.hibtest4.dao.UserDAOImpl.add(UserDAOImpl.java:13)
at Test.Test.tesAdd(Test.java:28)
at Test.Test.main(Test.java:18)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:169)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)
... 12 more
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/hibtest4/entity/Users.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:588)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1606)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1574)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1553)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1527)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1447)
at com.hibtest4.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at com.hibtest4.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at com.hibtest4.dao.BaseHibernateDAO.add(BaseHibernateDAO.java:17)
at com.hibtest4.dao.UserDAOImpl.add(UserDAOImpl.java:13)
at Test.Test.tesAdd(Test.java:28)
at Test.Test.main(Test.java:18)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.hibtest4.entity.Users
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
at org.hibernate.cfg.Configuration.add(Configuration.java:688)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:523)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:585)
... 11 more
Exception in thread "main" java.lang.NullPointerException
at com.hibtest4.dao.BaseHibernateDAO.add(BaseHibernateDAO.java:28)
at com.hibtest4.dao.UserDAOImpl.add(UserDAOImpl.java:13)
at Test.Test.tesAdd(Test.java:28)
at Test.Test.main(Test.java:18)
当你用工具自动加载的方法来配置HIbernate时报做出这样的错误,首先查看类库里面有没有MysqL的驱动,因为一些自动加载的是不会自动加载这个