title: How to start a Runnable?
body: <p>I need from my Class that implements <code>Runnable</code> was opening my Java EE application 7 Spring MVC. I declare my class in the <code>servlet.xml</code>:</p>
  
  <pre><code>&lt;beans:bean class="MyClass" scope="singleton"&gt;
  &lt;/beans:bean&gt;
  &lt;annotation-driven /&gt;
  &lt;context:component-scan base-package="MyClass" /&gt;
  &lt;context:annotation-config /&gt;
  </code></pre>
  
  <p>and this is my Class which has a <code>run()</code> method which is from all the X minute but it does not work. Why?</p>
  
  <pre><code>@Scope("singleton")
  @Component
  public class MyClass implements Runnable {
      private static final Logger LOG = LoggerFactory.getLogger(myClass.class);
  
      @Scheduled(initialDelay = 1000, fixedDelay = 10000)
      @Override
      @Transactional
      public void run() {
          LOG.debug("IN");
      }
  }
  </code></pre>
  
  <p>my servlet.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans 
  xmlns="http://www.springframework.org/schema/mvc" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:task="http://www.springframework.org/schema/task 
      http://www.springframework.org/schema/task 
      http://www.springframework.org/schema/task/spring-task-3.0.xsd"
   xmlns:beans="http://www.springframework.org/schema/beans" 
   xmlns:context="http://www.springframework.org/schema/context"
  xmlns:jpa="http://www.springframework.org/schema/data/jpa"
   xsi:schemaLocation="http://www.springframework.org/schema/mvc     http://www.springframework.org/schema/mvc/spring-mvc.xsd
      http://www.springframework.org/schema/beans    http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"&gt;
  
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com" /&gt;
  
  &lt;jpa:repositories base-package="com.dao" /&gt;
  
  &lt;!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --&gt;
  
  &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
  &lt;annotation-driven /&gt;
  
  &lt;!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources 
      directory --&gt;
  &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
  &lt;!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --&gt;
  &lt;beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
      &lt;beans:property name="suffix" value=".jsp" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean class="com.MyClass" scope="singleton"&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p></p>