我有一个服务类,具有进行异步调用的功能。下面提供了代码,

@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() );
            }

        }
    }
}


是否需要在类级别使用@EnableScheduling进行注释才能正常工作?

最佳答案

您应该用@EnableAsync注释您的主体。

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

09-11 18:14