title: Spring boot : access rest api from @Scheduled method
body: <p>I try below guild of schedule-task and it worked.</p>
  
  <p><a href="http://spring.io/guides/gs/scheduling-tasks/" rel="nofollow">http://spring.io/guides/gs/scheduling-tasks/</a></p>
  
  <p>next, I want to access web-api from <code>@Scheduled</code> annotated method, and add below dependency to my build.gradle, to use <code>RestTemplate</code>.</p>
  
  <pre><code>compile 'org.springframework.boot:spring-boot-starter-web:1.2.1.RELEASE'
  </code></pre>
  
  <p>but, below Exception occurs.</p>
  
  <pre><code>Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
  at my.pkg.Application.main(BatchApplication.java:14)
  </code></pre>
  
  <p>Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)</p>
  
  <p>do I need specific setting to use <code>RestTemplate</code> from <code>@Scheduled</code> method ?</p>
  
  <p>my full build.gradle is below, other files are same to guide.</p>
  
  <pre><code>buildscript {
    repositories {
      mavenLocal()
      mavenCentral()
    }
    dependencies {
      classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE'
    }
  }
  
  apply plugin: 'java'
  apply plugin: 'idea'
  apply plugin: 'spring-boot'
  
  repositories {
    mavenLocal()
    mavenCentral()
  }
  
  dependencies {
    compile 'org.springframework.boot:spring-boot-starter:1.2.1.RELEASE'
    // below line I added.
    compile 'org.springframework.boot:spring-boot-starter-web:1.2.1.RELEASE'
  }
  </code></pre>