Spring @Autowired annotation doesn't work in Java TimerTask

Why do you have ScheduledTask initialized in appilcationConfig.xml when you are already using @Component for that bean class. Remove this from your applicationContext.xml file.

<bean id="usersUpdateTask" class="com.demo.task.ScheduledTask">
</bean>

EDIT : Adding Spring Boot Sample.

Here is the sample code for @Scheduled with @Autowired in Spring Boot.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>springboot-scheduler</groupId>
<artifactId>springboot-scheduler-app</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <version>1.4.0.RELEASE</version>
    </dependency>
 </dependencies>
</project>

MySpringBootApp.java

package my.spring.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
public class MySpringBootApp {
    public static void main(String[] args) {
    SpringApplication.run(new Object[] { MySpringBootApp.class }, args);
   }
}

MyService.java

package my.spring.app;

import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.stereotype.Component;

@Component
public class MyService {    
public String getNextMessage(){
     return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
   }
}

ScheduledTask.java

package my.spring.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ScheduledTask {

@Autowired
MyService service;

@Scheduled(fixedRate = 5000)
public void process() {
    System.out.println("Processing at " + service.getNextMessage());
    }
}

Sample output

Processing at 2016-08-24T14:01:48
Processing at 2016-08-24T14:01:53
Processing at 2016-08-24T14:01:58

Hope this helps.

EDIT-2 : Adding Spring Boot Sample war file version. Tested with Tomcat 8. Following two files are changed. Others are same as above.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>springboot-scheduler</groupId>
<artifactId>springboot-scheduler-app</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.RELEASE</version>
     <relativePath/>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

</project>

MySpringBootApp.java

package my.spring.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
public class MySpringBootApp extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(MySpringBootApp.class);
  }

public static void main(String[] args) {

    SpringApplication.run(new Object[] { MySpringBootApp.class }, args);

    }
}