Could not Autowire. No beans of 'SimpMessagingTemplate' type found

by GarciaPL on Saturday 6 June 2015

My main IDE which is used at this time to develop for example Spring application is IntelliJ IDEA 13.1. My last project is built on Spring Framework 4. There is no so much problems with it, but there is one with Spring WebSocket. When you are going to autowire SimpMessagingTemplate object there is an error :

"Could not Autowire. No beans of 'SimpMessagingTemplate' type found"

The solution is very simple. Just add in your bean xml, in my case it's dispatcher-servlet.xml this line :

<context:component-scan base-package="org.springframework.web.socket.config"/>

As far as I know this problem is fixed in Intellij IDEA 14.0. Below you can read about ticket which is strictly related with this issue.

If this solution above did not work perhaps you need to move bean definition of your class which contains Autowired field of SimpMessagingTemplate to dispatcher-servlet.xml, I mean context which is pointed in your web.xml by org.springframework.web.servlet.DispatcherServlet.


Reference :
[1] Jetbrains IDEA-123964