Injecting externalized value into Spring annotation

前端 未结 5 966
一个人的身影
一个人的身影 2020-12-29 04:04

I\'ve been thinking around the Java feature that evaluates annotation values in compile-time and it seems to really make difficult externalizing annotation values.

H

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 04:52

    A better way to do this is to define the scheduling in xml using the task name space

    
    
    

    If you for some reason want to do it with annotation, you need to create an annotation that has another optional attribute where you can specify the property name or better still a property placeholder expression or Spel expression.

    @MyScheduled(fixedDelayString="${delay}")
    

提交回复
热议问题