不多说 直接上报错图吧
SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version网上说 检查下两个xml文件的配置是否错误 看了一下内容 没错啊 希望各位指教
16:50:05,573 WARN DTDEntityResolver:73 - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
%%%%%ERROR CREATING SESSIONFACTORY%%%%
org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:101)
at org.hibernate.cfg.Configuration.add(Configuration.java:513)
at org.hibernate.cfg.Configuration.add(Configuration.java:509)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:801)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2344)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2310)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2290)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2243)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
at com.hibernate.util.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:19)
at com.hibernate.dao.UserDAO.getUser(UserDAO.java:17)
at com.hibernate.service.UserService.valid(UserService.java:9)
at com.hibernate.service.UserService.main(UserService.java:18)
Caused by: org.dom4j.DocumentException: hibernate.sourceforge.net%20 Nested exception: hibernate.sourceforge.net%20
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:75)
... 13 more
Exception in thread "main" java.lang.NullPointerException
at com.hibernate.util.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:27)
at com.hibernate.dao.UserDAO.getUser(UserDAO.java:17)
at com.hibernate.service.UserService.valid(UserService.java:9)
at com.hibernate.service.UserService.main(UserService.java:18)
------解决方案--------------------
问题解决了吗,把那句thread配置加进去,用getCurrentSession的时候,必须配置线程同步,而且进行数据操作时候,开启事务。