简体   繁体   English

Spring 开机问题:无法解析import javax.persistence.Entity

[英]Spring boot problem: the import javax.persistence.Entity cannot be resolved

this is the error:这是错误:

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.

相关问题 无法在Springboot Gradle项目中解析@Entity和javax.persistence.Entity - Cannot resolve @Entity and javax.persistence.Entity in Springboot Gradle project Maven,春季启动-无法解析导入javax.validation - Maven, Spring-boot - The import javax.validation can not be resolved 即使存在jar,Eclipse也无法找到javax.persistence.Entity - Eclipse can't find javax.persistence.Entity even though jar is present 使用 spring 引导和 hibernate 的持久性问题,IllegalArgumentException:不是实体 - Persistence problem using spring boot with hibernate, IllegalArgumentException: Not an entity 在Spring Boot 2中使用Entity Manager时,没有类型为&#39;javax.persistence.EntityManager&#39;的合格Bean - No qualifying bean of type 'javax.persistence.EntityManager' when using Entity Manager with spring boot 2 GAE上的Spring Boot Rest应用程序抛出异常无法转换为javax.persistence.EntityManagerFactory“ - Spring Boot Rest App on GAE throws an exception cannot be cast to javax.persistence.EntityManagerFactory" @CrossOrigin无法解析-Spring Boot - @CrossOrigin cannot be resolved - Spring boot 在 Spring 引导中无法解析上下文 - context cannot be resolved in Spring Boot Spring Boot Application:- 无法解析导入 org.springframework.boot.SpringApplication - Spring Boot Application:- The import org.springframework.boot.SpringApplication cannot be resolved Spring Boot:javax.persistence.TransactionRequiredException:执行更新/删除查询 - Spring Boot: javax.persistence.TransactionRequiredException: Executing an update/delete query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM