我正在尝试使用 MySql 实现一个 Hibernate spring mvc 项目,并且在使用 @Entity 映射我的 Book 类时遇到问题。MySql 服务器与 Author.java 一起工作得很好,但是当我将 @Entity 映射到 Book 类时,我得到了 HTTP 状态 500 代码。
认为问题在于接受表的休眠方式,并且在我的 sessionFactory 会话期间没有初始化名为 Book 的表。休眠配置仅适用于我的 Author.java 类。
也许问题在于这本书类引用了我的作者?
public class Book {
private long ISBN;
private String title;
private String releaseYear;
private Author author;
错误行: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'homeController': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [no/package/config/HibernateConfig.class]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: my.package.model.Author, at table: Book, for columns: [org.hibernate.mapping.Column(author)]
慕后森
慕尼黑8549860
相关分类