Java Spring重试不工作,并且获取MaxAttemptsPression值异常

Java Spring重试不工作,并且获取MaxAttemptsPression值异常,java,spring-mvc,websphere,websphere-portal,spring-retry,Java,Spring Mvc,Websphere,Websphere Portal,Spring Retry,我正在使用spring-retry-1.2.0.RELEASE.jar并在服务方法中使用下面的Retryable注释 @Retryable(value = {CustomException.class}, maxAttemptsExpression = "#{'${max.retry.attempts}'}", backoff = @Backoff(delayExpression = "#{'${retry.delay}'}")) 在下面看到

我正在使用
spring-retry-1.2.0.RELEASE.jar
并在服务方法中使用下面的
Retryable
注释

@Retryable(value = {CustomException.class}, 
            maxAttemptsExpression = "#{'${max.retry.attempts}'}", 
            backoff = @Backoff(delayExpression = "#{'${retry.delay}'}"))
在下面看到的日志中,由于
maxAttemptsExpression
值和使用
integer.ParseInt/integer.ValueOf
时的相同错误,出现异常

org.springframework.expression.spel.SpelEvaluationException: EL1001E:(位置0):类型转换问题,无法从转换 java.lang.String到java.lang.Integer

我只在少数@Retryable服务方法上看到这个异常,其余@Retryable方法工作正常。我不知道这里发生了什么,我们在点击注释之前也看到了值

删除
{'
}
(包括单引号)

这里不需要
#{…}

您还应该升级到1.2.1.0版本

编辑


一定有别的事情发生了;两种形式对我都很好

@SpringBootApplication
@EnableRetry
public class So48309090Application {

    public static void main(String[] args) {
        SpringApplication.run(So48309090Application.class, args);
    }

    @Bean
    public ApplicationRunner runner(Foo foo) {
        return args -> {
            try {
                foo.foo();
            }
            catch (RuntimeException e) {

            }
            try {
                foo.bar();
            }
            catch (RuntimeException e) {

            }
        };
    }

    @Component
    public static class Foo {

        @Retryable(maxAttemptsExpression = "${max.attempts}")
        public void foo() {
            System.out.println("foo");
            throw new RuntimeException("c");
        }

        @Retryable(maxAttemptsExpression = "#{'${max.attempts}'}")
        public void bar() {
            System.out.println("bar");
            throw new RuntimeException("c");
        }

    }

}
应用程序属性

max.attempts=5


EL1001E
也是找不到属性时引发的错误。尝试使用
@Value
将您的属性绑定到实例变量,并检查是否确实从属性中正确读取了该值。

更改为下文并更新为1.2.1 RELEASE@Retryable(Value={CustomException.class},MaxAttemptsPression=“${max.retry.attempts}”后出现相同的异常,backoff=@backoff(delayExpression=“${retry.delay}”))肯定发生了其他事情;两种形式都适合我;请参阅对我的答案的编辑。spring-retry。
max.attempts=5
foo
foo
foo
foo
foo
bar
bar
bar
bar
bar