hibernate Unknown entity异常

这个异常我在网上找了很多,后来经过测试(修改bean的hibernate配置文件里的属性名字)发现问题是spring没有扫描到实体类的xml文件,如果放在resource文件夹下,applicationContext.xml要写

<property name="mappingDirectoryLocations" value="classpath:/" ></property> 

最好是和bean实体类放在一个文件夹里

    <property name="mappingDirectoryLocations" value="classpath:bean" ></property> 

猜你喜欢

转载自www.cnblogs.com/withbear/p/11855404.html