Spring-boot-jpa 报错:AnnotationException: No identifier specified for entity

Spring-boot-jpa 报错:

AnnotationException: No identifier specified for entity

在利用Spring-boot-jpa 开发时,出现报错信息

[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:
Invocation of init method failed; nested exception is org.hibernate.
<p>AnnotationException: No identifier specified for entity:
在这里,明明在@entity 类中已经配置好相应的@Id注解,却还是无法正常通过运行

报错的原因是@Id的包引错了:
在这里,我们却错误的使用了
	import org.springframework.data.annotation.Id;

而我们所需要的是

	import javax.persistence.Id;

只需要更正引用便可将问题解决

像这种小细节,一般很难察觉到,但是出错的时候便很难察觉到,所以一定要养成细心的好习惯

全部评论

相关推荐

点赞 评论 收藏
分享
待现的未见之事:起码第一句要把自己的优势说出来吧。比如什么xx本27届学生,随时到岗....
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务