I've written a task scheduler in Spring. Its running properly. Now my condition is I'm trying to inject one bean into the listener. But, it returns me null object. But if the same bean is injected into a controller/component, it works fine. Please let me know if I need to make any modifications.
Here is my code
My configurations in application context configuration file
<task:scheduler id="testScheduler" pool-size="1" />
<bean id="testListener"
class="com.dev.util.TestListener" >
</bean>
<task:scheduled-tasks scheduler="testScheduler">
<task:scheduled ref="testListener" method="run"
fixed-delay="60000" />
</task:scheduled-tasks>
The bean which I'm trying to inject
<bean id="getEmployeeServiceAdapter" class="com.dev.adapter.GetEmployeeServiceAdapter">
</bean>
And finally my class
public class TestListener {
@Autowired
static
GetEmployeeServiceAdapter getEmployeeServiceAdapter;
public void run() throws Exception{
System.out.println("Hii");
// Code
}
}
when I do in debug mode, and place my cursor on the object, it gets as null