No qualifying bean of type org.springframework.scheduling.TaskScheduler defined

Asked on November 18, 2015
Hi
I am working with spring task scheduler and getting the following error.
How to resolve.
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:371) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331) ~[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.finishRegistration(ScheduledAnnotationBeanPostProcessor.java:183) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:162) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:85) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:775) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483) [spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE]

Replied on November 19, 2015
I observed one thing that.
If am starting my spring scheduler using the code
public static void main(String[] args) throws SQLException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(AppConfig.class);
ctx.refresh();
}
Then the error is there in the log but scheduler is running. And if I am starting my scheduler using the following code then there is no error in the log.
public static void main(String[] args) throws SQLException {
ApplicationContext context = SpringApplication.run(AppConfig.class);
}