title: Could not autowire. No beans of SimpMessagingTemplate type found
body: <p>I am configuring Websockets in Spring basically by following the guide provided in the documentation.</p>
  
  <p>I am currently trying to send a message from the server to the client as explained in the section "<a href="http://docs.spring.io/spring/docs/4.0.2.RELEASE/spring-framework-reference/htmlsingle/#websocket-stomp-handle-send">Sending messages from anywhere</a>"  </p>
  
  <p>Following the example, you can Autowire a class called SimpMessagingTemplate</p>
  
  <pre><code>@Controller
  public class GreetingController {
  
      private SimpMessagingTemplate template;
  
      @Autowired
      public GreetingController(SimpMessagingTemplate template) {
          this.template = template;
      }
  
      @RequestMapping(value="/greetings", method=POST)
      public void greet(String greeting) {
          String text = "[" + getTimestamp() + "]:" + greeting;
          this.template.convertAndSend("/topic/greetings", text);
      }
  
  }
  </code></pre>
  
  <p>However, my current project cannot find the bean "SimpMessagingTemplate". (Intellij: 'Could not autowire. No beans of SimpMessagingTemplate type found'.</p>
  
  <p>I have check several examples in the internet but I cannot find how to get Spring to create an instance of SimpMessagingTemplate. How can I Autowire it ?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I decided to send some more background information. This is my current websocket configuration:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:websocket="http://www.springframework.org/schema/websocket"
         xsi:schemaLocation="
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/websocket
          http://www.springframework.org/schema/websocket/spring-websocket-4.0.xsd"&gt;
  
          &lt;!-- TODO properties to be read from a properties file --&gt;
          &lt;websocket:message-broker application-destination-prefix="/app"&gt;
              &lt;websocket:stomp-endpoint path="/new_session" &gt;
                  &lt;websocket:sockjs/&gt;
              &lt;/websocket:stomp-endpoint&gt;
              &lt;websocket:simple-broker prefix="/topic"/&gt;
          &lt;/websocket:message-broker&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Websocket works with this controller</p>
  
  <pre><code>@Controller
  public class SessionController {
  
      private static final Logger log = LoggerFactory.getLogger(SessionController.class);
  
      @MessageMapping("/new_session")
      @SendTo("/topic/session")
      public SessionStatus newSession(Session session) throws Exception {
      Thread.sleep(3000); // simulated delay
      log.info("Response sent !!");
      return new SessionStatus("StatusReport, " + session.toString() + "!");
      }
  }
  </code></pre>
  
  <p>I just not sure how to to make this work</p>
  
  <pre><code>public class SessionController {
  
      private static final Logger log = LoggerFactory.getLogger(SessionController.class);
  
      private SimpMessagingTemplate template;
  
      @Autowired
      public SessionController(SimpMessagingTemplate template) {
      this.template = template;
      }
  
  }
  </code></pre>
  
  <p>As the bean "SimpMessagingTemplate template" is not found. Spring documentation does not offer more details regarding this matter.</p>
  
  <p><strong>EDIT</strong>: Example of working code in <a href="https://github.com/tk421/spring-stomp">github</a></p>