From yml to Java CronExpression Object conversion failed

21 Views Asked by At

I've just upgraded my code from java 11, spring 2.7.4 to java 17, spring 3.2.2 and now I'm facing this weird issue: my code cannot parse anymore what I've defined inside my yml configuration file to java CronExpression object, getting instead this error:

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'recovery.cron' to org.springframework.scheduling.support.CronExpression:

    Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [@jakarta.validation.constraints.NotNull org.springframework.scheduling.support.CronExpression]

Action:

Update your application's configuration


Process finished with exit code 1

my yml file looks like this:

recovery:
  cron: '0 31 0/1 * * ?'

and the java class defining this configuration object is like that:

import lombok.Getter;
import lombok.Setter;
import org.springframework.scheduling.support.CronExpression;
import org.springframework.validation.annotation.Validated;

import jakarta.validation.constraints.NotNull;

@Validated
@Getter
@Setter
public class RecoverySettings {

    @NotNull
    private CronExpression cron;

}

I can't figure out what's happening different from java 11

0

There are 0 best solutions below