2017-03-17 121 views
0

在SpringBoot應用程序中使用Katharsis和JPA需要使用@JsonApiToMany註釋JPA的@OneToMany關係,並使用@JsonApiToOne註釋@ManyToOne。我想知道是否有任何方法可以避免重複的註釋? 有沒有更簡單的方法將Katharsis集成到SpringBoot + JPA應用程序中?Katharsis和JPA註釋

回答

0

你可以建立你自己的刻板印象註釋,舉例

@Target({ElementType.FIELD, ElementType.METHOD}) 
@Retention(RetentionPolicy.RUNTIME) 
@Documented 
@JsonApiToMany 
@OneToMany 
public @interface CustomOneToMany{ 

    // .... 
} 

Meta-annotations

+0

我猜多對一和JsonApiToMany不會讓我創建meta-annotation - @ Target({METHOD,FIELD}) - @ Retention(RUNTIME) public - @ interface ManyToOne { – ninux