Spring 在class 层注解@EnableScheduling

Spring Annotate in the class level with @EnableScheduling

我有一项服务 class 具有进行异步调用的功能。代码如下,

@Service
public class EllaService {

    @Async
    public void invokeEllaAsync( final IrisBo irisBo ) throws EllaGatewayUnsuccessfulResponseException {

        if( !isTrafficIgnored( irisBo ) ) {
            try {
                callEllaService( irisBo );
            }
            catch( EllaGatewayUnsuccessfulResponseException ex ) {
                throw new EllaGatewayUnsuccessfulResponseException( ex.getMessage(), ex.getCause() );
            }

        }
    }
}

我是否需要在 class 关卡中使用 @EnableScheduling 注释才能正常工作?

你应该用 @EnableAsync 来注释你的 main。

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/annotation/EnableAsync.html