Spring: How to inject values to fields annotated by custom annotation

Viewed 498

my custom annotation:

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface KmsProperty {
    String key() default "";
}

bean:

public class Prop {
    @KmsProperty(key = ApiKeyConstant.SERVICE_SECRET)
    private String serviceSecret;
}

I want to inject values to all fields annotated by @KmsProperty, these values come from different sources(property files, or third-party key management services), how can I do that on application startup?

0 Answers
Related