Attribute "not-null" must be declared for element type "property"解决办法

Attribute "not-null" must be declared for element type "property"解决办法

在hiberante中编写映射文件时语法报错,原因是xml的DTD文件头不对

这是因为我是复制了hibernate.cfg.xml的头部文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">



映射的文件,应该改为mapping的头文件就行了

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



修改后,再看语法检查就不报错了!

原文地址:https://www.cnblogs.com/mxm2005/p/4947428.html