Java 如何在spring boot项目中为StoredProcedure和列创建自定义注释?
我需要为StoredProcedure和Column创建自定义注释。 例子: @具有三个参数的StoredProcess,如query、structname、structArrayName 和@Column with有五个字段,如name、position、type和requiredJava 如何在spring boot项目中为StoredProcedure和列创建自定义注释?,java,spring,spring-boot,Java,Spring,Spring Boot,我需要为StoredProcedure和Column创建自定义注释。 例子: @具有三个参数的StoredProcess,如query、structname、structArrayName 和@Column with有五个字段,如name、position、type和required 有谁能帮助我如何在实体类中创建和应用它吗?我们可以添加元注释来指定自定义注释的范围和目标。 例: @Retention(RUNTIME) @Target(TYPE) public @interface Store
有谁能帮助我如何在实体类中创建和应用它吗?我们可以添加元注释来指定自定义注释的范围和目标。 例:
@Retention(RUNTIME)
@Target(TYPE)
public @interface StoredProcedure {
String query ();
String structName ();
String structArrayName ();
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Column {
public String name();
public int position ();
public String datePattern () default "MM/dd/yyyy HH:mm:ss.SSSSSS";
public String defValue () default "";
public boolean required () default false;
public String actualType () default "na";
}
// we can apply annotations in class level and field level.
@StoredProcedure(query = "{}", structName = "", structArrayName = "")
public class Data {
@Column(name = "id", position = 1, actualType = "string", required = true)
@Validate(length = )
public String id;
@Column(name = "name", position = 2, actualType = "number")
@Validate(length = )
public Long name;
}