![]() I have also tried the string variant "initialDelayString", but that does not work either. I have tried to make delayUntilNextHour a static final (constant), but it still does not work. When we access an Enum value using (), it will show as and error as Attribute value must be constant. ![]() I cannot insert "delayUntilNextHour" into the initialDelay parameter of I was wondering if anyone can point me in the right direction in how to get around this. It is possible to use some compile time tools (ant, maven) to config it if the value is known before you try to run the program. See also here: How to supply value to an annotation from a Constant java. ![]() See also here: How to supply value to an annotation from a Constant java It is possible to use some compile time tools (ant, maven) to config it if the value is known before you try to run the program. The value for an annotation must be a compile time constant, so there is no simple way of doing what you are trying to do. LocalDateTime nextHour = now.plusHours(1).withMinute(0).withSecond(0).withNano(0) ÄelayUntilNextHour = now.until(nextHour, delayUntilNextHour, fixedRate=3600000) //Runs every hour The value for an annotation must be a compile time constant, so there is no simple way of doing what you are trying to do. Note: Jackson omits any quotation marks inside the String that is returned by. However, when I try to use the variable inside of a annotation, I get the following error message: The value for annotation attribute Scheduled.initialDelay must be a constant expression private LocalDateTime now annotation, you can define the way in which the Java object is to be serialized. In my code below, I tried to calculate the initial delay inside of a annotation. This way, the scheduled task can run at exact hours like 1pm.2pm.3pm etc. ![]() The catch is that when the application starts up, it should calculate the duration until the next hour and use that value as a initial delay. I am using Spring MVC and I am trying to write a scheduled task that runs every hour. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |