工欲善其事,必先利其器
Maven依赖的Spring-websocket的jar
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
spring-websocket核心类是:WebSocketConfig
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
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/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/websocket http://www.springframework.org/schema/websocket/spring-websocket.xsd">
<bean id="websocket" class="com.lgy.websocket.SystemWebSocketHandler" />
<websocket:handlers>
<websocket:mapping path="/webSocketServer" handler="websocket" />
<websocket:handshake-interceptors>
<bean class="com.lgy.interceptor.WebSocketHandshakeInterceptor" />
</websocket:handshake-interceptors>
</websocket:handlers>
</beans>
等价于:
@Configuration
//@Ena