en *_*pes 7 java jpa spring-data spring-data-jpa spring-boot
我刚刚创建了一个具有此依赖项的 Maven 项目
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但我意识到所有这些类都没有找到:
import javax.persistence.*
Run Code Online (Sandbox Code Playgroud)
所以我必须将依赖项更改为
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我觉得很奇怪,因为上次更新来自Aug 21, 2017
没有包含 javax.persistence 的 spring 依赖项???
Spring Data JPA 本身并不是 JPA 规范的实现。它是构建在 JPA 之上的抽象,需要 JPA 实现(通常是 Hibernate)才能运行。JPA 实现提供了这些javax.persistence类。因此,如果依赖于org.springframework.data:spring-data-jpaalone,javax.persistence类将不会出现在类路径上。
如果您使用 Spring Boot 的 Data JPA 启动器 ( org.springframework.boot:spring-boot-starter-data-jpa),则它依赖于 Spring Data JPA 和 Hibernate。然后,Hibernate 依赖于javax.persistenceAPI,这使得它的类可用于应用程序的代码。
| 归档时间: |
|
| 查看次数: |
3763 次 |
| 最近记录: |