Java 如何从Spring值注释中检索字段名?

Java 如何从Spring值注释中检索字段名?,java,spring,Java,Spring,在我的班上,我有: @Component public class AwgTekConsumerProperties { @Value("${awgtek_topic_consumer.default_thread_pool_size:10}") private Integer defaultThreadPoolSize; @Value("${awgtek_topic_consumer.default_keep_alive_time:10}") private

在我的班上,我有:

@Component
public class AwgTekConsumerProperties {

    @Value("${awgtek_topic_consumer.default_thread_pool_size:10}")
    private Integer defaultThreadPoolSize;

    @Value("${awgtek_topic_consumer.default_keep_alive_time:10}")
    private Integer defaultKeepAliveTime;

    ....
}
我想检索字段值列表,即
[“awgtek\u主题\u使用者.默认线程\u池\u大小”,“awgtek\u主题\u使用者.默认保持活动\u时间”,…]

我尝试的是:
Set consumperPropertyNames=FieldUtils
.getFieldsListWithAnnotation(AwgTekConsumerProperties.class,Value.class).stream()
.map(field->((Value)array.stream(field.getDeclaredAnnotations()).filter(a->a instanceof Value.findFirst().get()).Value())
.collect(收集器.toSet())

但这将导致整个字段名,即
[“${awgtek_topic_consumer.default_thread_pool_size:10}”,“${awgtek_topic_consumer.default_keep_alive_time:10}”。]
包括Spring EL和默认值。
有没有一种方法可以使用Spring实用程序或其他优雅的方法只解析字段名?我试图研究Spring表达式语言,但找不到解析它的方法,但我可能错过了一些东西。是否有比执行
String.indexOf
等更好的方法?

您需要在该特定类中使用属性名称,还是需要加载到Spring上下文中的所有系统/环境属性?仅需要该类中的属性名称。转介