Spring boot Spring重试maxAttempts不起作用

Spring boot Spring重试maxAttempts不起作用,spring-boot,spring-retry,Spring Boot,Spring Retry,一个非常简单的HelloWorld测试 @Log4j2 @服务 @启用重试 @使能调度 公共类MyBeanImpl{ @计划(cron=“0/2****?”) @可重试(值={RuntimeException.class},最大尝试次数=4,退避=@backoff(延迟=10000)) 公共无效附表(){ log.info(“Foo-sched a={}”,a++); 抛出新的运行时异常(“Foo”); } } @恢复 公共无效恢复(运行时异常e){ //..... } //Junit类

一个非常简单的HelloWorld测试

@Log4j2
@服务
@启用重试
@使能调度
公共类MyBeanImpl{
@计划(cron=“0/2****?”)
@可重试(值={RuntimeException.class},最大尝试次数=4,退避=@backoff(延迟=10000))
公共无效附表(){
log.info(“Foo-sched a={}”,a++);
抛出新的运行时异常(“Foo”);
}    
}
@恢复
公共无效恢复(运行时异常e){
//.....
}
//Junit类在这里,对于简单的POC测试,我不使用接口类,只使用实现类
@RunWith(SpringRunner.class)
@春靴测试
@Log4j2
@上下文配置
公共类MyBeanImplTest{
@自动连线
豆豆;
私有字符串输入=“HelloWorld”;
@试验
公共无效附表(){
_sched();
}
问题:

我将maxtures设置为1,它运行1次。为什么?

我设置maxAttempts=2,它总是运行3次。为什么

我将maxtures设置为4,但是它运行了8次。为什么


我将maxtures设置为6,它运行了11次。为什么?

可能是因为它被调度,并且被测试用例调用


查看信息日志中的线程名称。

因为我不熟悉Spring Retry和Spring SchedulerConfig。我按照您的建议并启用调试级别,我发现还有另一个线程。在我的例子中,它被称为我的计划任务池,池大小被设置为10。很抱歉我犯了一个愚蠢的错误。
java@Configuration公共类SchedulerConfig实现s SchedulingConfigurer{private final int POOL_SIZE=10;//..threadPoolTaskScheduler.setThreadNamePrefix(“我的计划任务池-”);threadPoolTaskScheduler.initialize();scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler);}}