According to Spring documentation, the @Scheduled annotation can only be applied to methods without arguments. Applying @Scheduled to
a method with arguments will result in a runtime error.
Transform method annotated with @Scheduled into a no-arg method.
public class ExampleService {
@Scheduled(fixedRate = 5000)
public void scheduledTask(String param) { // non compliant, method has an argument. It will raise a runtime error.
// Task implementation
}
}
public class ExampleService {
@Scheduled(fixedRate = 5000)
public void scheduledTask() { // compliant, no-arg method
// Task implementation
}
}