springboot 使用jpa时遇到bug

问题1如下

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productCategoryRepository' defined in com.wechat.selectfood.dao.ProductCategoryRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

解决方案

  • 启动类上加上如下注解

问题二

by: org.hibernate.AnnotationException: No identifier specified for entity: com.itmumu.Entity.User

解决方法

  • 加入如下注解
原文地址:https://www.cnblogs.com/jachinlin/p/13530671.html