- error

Caused by: java.lang.IllegalStateException: More than one TaskExecutor bean exists within the context, and none is named 'taskExecutor'. Mark one of them as primary or name it 'taskExecutor' (possibly as an alias); or specify the AsyncConfigurer interface and implement getAsyncExecutor() accordingly.

at org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor.setBeanFactory(AsyncAnnotationBeanPostProcessor.java:135)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1597)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1565)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)

... 20 more

Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.core.task.TaskExecutor] is defined: expected single matching bean but found 6: clientOutboundChannelExecutor,messageBrokerTaskScheduler,clientInboundChannelExecutor,brokerChannelExecutor,taskScheduler,defaultSockJsTaskScheduler

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:366)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:332)

at org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor.setBeanFactory(AsyncAnnotationBeanPostProcessor.java:128)

... 23 more




- resolved
* Add the bean at Spring application context configuration

@Configuration
@EnableAsync
public class AppContext extends WebMvcConfigurationSupport {
...

@Bean
public Executor taskExecutor() {
return new SimpleAsyncTaskExecutor();
}

}




'Framework & Platform > Spring' 카테고리의 다른 글

ThreadPoolTaskScheduler initialize method  (0) 2020.03.29
spring - ServletContext  (0) 2015.07.16
spring - headers="Accept=*/*"  (0) 2014.12.26
spring - Get current ApplicationContext  (0) 2014.10.06
spring - restTemplate example  (0) 2014.09.12
Posted by linuxism
,