Hibernate 5.3.1 版本下出现此问题:java
INFO: HHH000206: hibernate.properties not found
Exception in thread “main” 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:165)
at org.hibernate.cfg.Configuration.configure(Configuration.java:258)
at org.hibernate.cfg.Configuration.configure(Configuration.java:244)
at test.Service.saveModify(Service.java:34)
at test.App.main(App.java:15)
Caused by: javax.xml.bind.UnmarshalExceptionmysql
jdbc:mysql://localhost:3306/lvlang?" +"autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
1
后参考对实体 “characterEncoding” 的引用必须以 ‘;’ 分隔符结尾,将&符号重写成:&以下:web
jdbc:mysql://localhost:3306/lvlang?" +"autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
1
如是问题解决。sql
其实根据异常提示–“Message: 对实体 “useUnicode” 的引用必须以 ‘;’ 分隔符结尾”,也知道应该是useUnicode附近写的有问题。apache
前半截异常提示,容易误导人觉得是配置文件或者标签名的问题:svg
INFO: HHH000206: hibernate.properties not found
Exception in thread “main” org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE hibernate.cfg.xml. Message: null
1
2
其实真正的问题出在caused by后面:ui
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[8,113]
Message: 对实体 “useUnicode” 的引用必须以 ‘;’ 分隔符结尾。
at
1
2
3
另外,Eclipse 对于 XML 文件的错误提示,实在不友好,如上错误的 xml 写法,Eclipse 的错误提示是The word ‘localhost’ is not correctly spelled + The word ‘lvlang’ is not correctly spelled,误导人觉得是localhost或者lvlang写法有问题。spa