【发布时间】:2020-12-08 06:48:12
【问题描述】:
在使用spring-boot-starter-data-mongodb时包含和使用JPA Entity Lifecycle Events的正确方法是什么?
我的 pom.xml 依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
我的类路径没有看到以下任何 JPA 注释:
@PrePersist
@PostPersist
@PreRemove
@PostRemove
@PreUpdate
@PostUpdate
@PostLoad
【问题讨论】:
-
为什么要包含 JPA 依赖项? JPA和MongoDB没关系?
标签: spring-boot spring-data-jpa spring-data spring-boot-starter