org.hibernate.MappingException: Unknown entity: annotations.Users

前端 未结 19 1578
情歌与酒
情歌与酒 2020-12-01 07:11

Consider the hierarchy :

\"enter

And the following classes and xml :

19条回答
  •  醉梦人生
    2020-12-01 07:55

    I was having similar issue and adding

     sessionFactory.setAnnotatedClasses(User.class);
    

    this line helped but before that I was having

    sessionFactory.setPackagesToScan(new String[] { "com.rg.spring.model" });
    

    I am not sure why that one is not working.User class is under com.rg.spring.model Please let me know how to get it working via packagesToScan method.

提交回复
热议问题