Accessing property values in Annotations

后端 未结 2 1464
借酒劲吻你
借酒劲吻你 2021-01-25 11:28

I want to access a property value in my annotation, as an attribute\'s value.

For ex. in my property file I have an entry expression: 3/10 * * * * ?.

<
相关标签:
2条回答
  • 2021-01-25 12:07

    You can try to use the APT (annotation processing tool) to replace the value in the annotation with a value from the property file.

    0 讨论(0)
  • 2021-01-25 12:22

    From spring 3.0.1 you can do it like this @Scheduled(cron = "${rates.refresh.cron}")

    Refer to http://forum.springsource.org/showthread.php?83053-Feature-Scheduled-with-Value-cron-expression

    However, you cannot do this for fixDelay and fixRate due to type casting problem (fixDelay expects value in long, while annotation return String only). Check Mark's comments in https://jira.springsource.org/browse/SPR-6670

    0 讨论(0)
提交回复
热议问题