如何使用 Spring 创建一个具有来自 children 的注释的 parent 界面?

How to make a parent interface who has some annotations from children using Spring?

我有很多模型 类 具有相同的注释:

Child:

@Entity
@DynamicUpdate
@Table(name = "STATUS")
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true, doNotUseGetters = 
true)
public class Child{...}

Parent:

public @interface Parent
{...}

我想在 parent 中设置注释。所以 child 在一个简单的注释 @Parent

中实现

以及如何将参数从Child传递到Parent?

您可以将注释传递给 Parent 注释:

@Entity
@DynamicUpdate
@Table(name = "STATUS")
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true, doNotUseGetters = true)
public @interface Parent {
}

并在你身上使用它 Child class:

@Parent
public class Child {
}