文章出處

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'articleDaoImpl': Injection of resource methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.wangzhe.model.Keyword.Articles in com.wangzhe.model.Article.keywords

 

上面是錯誤的關鍵部分

  錯誤原因:在one-to-many注解配置: @OneToMany (mappedBy = "Articles"),mappedBy指向的是要關聯的屬性,而不是要關聯的類,
        如果這樣配置,hibernate則會找com.wangzhe.model.Keyword類下面的Articles 屬性。但實際上沒有這個屬性,就會報上面的異常
   方法:指定到實際關聯的屬性:即:@OneToMany (mappedBy = "articles ")


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()