withSchedule(ScheduleBuilder<SBT>) in the type TriggerBuilder<Trigger> is not applicable for arguments (MutableTrigger)

750 views Asked by At

Following code gives error like : The method withSchedule(ScheduleBuilder) in the type TriggerBuilder is not applicable for the arguments (MutableTrigger)

   public static Trigger buildTriggerForJob(int hours, int minutes, int seconds, String name, String groupName) {
            return org.quartz.TriggerBuilder
                    .newTrigger()
                    .withIdentity(name, groupName)
                    .withSchedule(
                            SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(hours).withIntervalInMinutes(minutes)
                            .withIntervalInSeconds(seconds).repeatForever().build());
        }
1

There are 1 answers

1
Vartlok On BEST ANSWER

There is no need to do it .build(). Try without it.

public static Trigger buildTriggerForJob(int hours, int minutes, int seconds, String name, String groupName) {
    return org.quartz.TriggerBuilder
           .newTrigger()
           .withIdentity(name, groupName)
           .withSchedule(
                SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(hours).withIntervalInMinutes(minutes)
                .withIntervalInSeconds(seconds).repeatForever()).build();
 }