java - Could not autowire. No beans of SimpMessagingTemplate type found -


i configuring websockets in spring following guide provided in documentation.

i trying send message server client explained in section "sending messages anywhere"

following example, can autowire class called simpmessagingtemplate

@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);     }  } 

however, current project cannot find bean "simpmessagingtemplate". (intellij: 'could not autowire. no beans of simpmessagingtemplate type found'.

i have check several examples in internet cannot find how spring create instance of simpmessagingtemplate. how can autowire ?

edit:

i decided send more background information. current websocket configuration:

<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">          <!-- todo properties read properties file -->         <websocket:message-broker application-destination-prefix="/app">             <websocket:stomp-endpoint path="/new_session" >                 <websocket:sockjs/>             </websocket:stomp-endpoint>             <websocket:simple-broker prefix="/topic"/>         </websocket:message-broker> </beans> 

websocket works controller

@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() + "!");     } } 

i not sure how to make work

public class sessioncontroller {      private static final logger log = loggerfactory.getlogger(sessioncontroller.class);      private simpmessagingtemplate template;      @autowired     public sessioncontroller(simpmessagingtemplate template) {     this.template = template;     }  } 

as bean "simpmessagingtemplate template" not found. spring documentation not offer more details regarding matter.

edit: example of working code in github

strange, because when use websocket namespace, "message-broker" element causes creation of simpmessagingtemplate bean should available inject. both controller , websocket namespace in same applicationcontext or perhaps 1 in "root" context , other in dispatcherservlet context?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -