小编Yas*_*nou的帖子

未在 Spring Boot 中调用的 JPA 实体上的 @PostConstruct

我正在使用 Spring Boot 并且我在我的 JPA 实体中添加了 @PostConstrcut 注释,如图所示,但是当实体被实例化时,这个拦截器永远不会被调用。

@Entity
public class MyTableName implements java.io.Serializable {
   // all attributes
   @PostConstruct
   public void init(){
     // This code never called
     System.out.println("PostConstruct");
   }
}
Run Code Online (Sandbox Code Playgroud)

java spring jpa postconstruct spring-boot

2
推荐指数
1
解决办法
4882
查看次数

标签 统计

java ×1

jpa ×1

postconstruct ×1

spring ×1

spring-boot ×1