[英]Spring boot problem: the import javax.persistence.Entity cannot be resolved
i add this code:我添加这段代码:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
in pom.xml but this error still在 pom.xml 但这个错误仍然存在
You seem to be importing the wrong dependency.您似乎导入了错误的依赖项。 If you would like to use the @Entity annotation import the following dependency:
如果您想使用 @Entity 注释导入以下依赖项:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
You can instead import the Spring data JPA package:您可以改为导入 Spring 数据 JPA package:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Which will allow you to use the @Entity annotation.这将允许您使用 @Entity 注释。
Also make sure to update your project when the new dependencies are added.还要确保在添加新依赖项时更新您的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.