2017-12-27 18 views
0

休眠错误我得到这个错误,当我尝试启动编译我的项目上的hibernate.cfg.xml

dic 27, 2017 11:55:50 AM org.hibernate.Version logVersion 
INFO: HHH000412: Hibernate Core {5.2.12.Final} 
dic 27, 2017 11:55:50 AM org.hibernate.cfg.Environment <clinit> 
INFO: HHH000206: hibernate.properties not found 
Initial SessionFactory creation 
failed.org.hibernate.internal.util.config.ConfigurationException: Unable to 
perform unmarshalling at line number 0 and column 0 in RESOURCE 
hibernate.cfg.xml. Message: null 
Exception in thread "main" java.lang.ExceptionInInitializerError 
    at progetto1java.HibernateUtil.buildSessionFactory(HibernateUtil.java:15) 
    at progetto1java.HibernateUtil.<clinit>(HibernateUtil.java:8) 
    at progetto1java.Gestore_Utenti.VerificaUtente(Gestore_Utenti.java:59) 
    at progetto1java.Sistema.main(Sistema.java:48) 
Caused by: org.hibernate.internal.util.config.ConfigurationException: Unable 
    to perform unmarshalling at line number 0 and column 0 in RESOURCE 
    hibernate.cfg.xml. Message: null 
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:133) 
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65) 
    at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57) 
    at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:258) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:244) 
    at progetto1java.HibernateUtil.buildSessionFactory(HibernateUtil.java:12) 
... 3 more 
Caused by: javax.xml.bind.JAXBException 
- with linked exception: 
[java.lang.ClassNotFoundException: 
com.sun.xml.internal.bind.v2.ContextFactory] 
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:241) 
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:477) 
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656) 
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) 
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:122) 
... 9 more 
Caused by: java.lang.ClassNotFoundException: 
com.sun.xml.internal.bind.v2.ContextFactory 
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) 
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) 
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source) 
    at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:594) 
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:239) 
... 13 more 

我仔细看看我的配置文件,但我现在有什么问题不.. 这些都是为了我的配置文件

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
    "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory> 
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sistema_musicale</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password"></property> 
     <property name="hibernate.connection.pool_size">1</property> 
     <property name="hibernate.current_session_context_class">thread</property> 
     <property name="hbm2ddl.auto">create</property> 
     <property name="hibernate.show_sql">true</property> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
     <mapping class="progetto1java.Utente"/> 
     <mapping class="progetto1java.Brano"/> 

    </session-factory> 
</hibernate-configuration> 

和hibernate class util。

class hibernate to create session

对不起我用图片代替代码对,但我有压痕问题...

+1

分享你的'hibernate.cfg.xml'文件,你应该把这个文件放在类路径中 –

+1

你使用什么Java版本?如果Java 9,尝试在8版本下运行。 – borino

回答

0

请确保您“的hibernate.cfg.xml”文件存在于“源”文件夹你的项目。

相关问题