Refactor of the Spring Websocket Guide using STOMP to use Angular 2
Checkout this project, or to re-create from scratch:
- Create new Spring boot initializer project at https://start.spring.io/
- Add Websocket, Lombok & Devtools Dependencies
- Unpack project to workspace
- Add code as per the Spring Websocket Guide, with some modifications
-
Condensed
Greeting.java
andHelloMessage.java
implementations (care of Lombok) -
WebSocketConfig.java
has amended stomp registry endpoint -
Refactored web assets for Angular 2, initially created using angular-cli
cd src/main ng new -sg -st ng cd ng # as per http://devsullo.com/github/angular2-stomp-over-websocket-service/ npm i --save stompjs npm i --save sockjs-client npm i --save ng2-stomp-service # update typings.d.ts & app.module.ts
-
-
Run bootRun Gradle task to launch server (builds ng app too)
gradle bootRun
-
Point a Browser at http://localhost:8080/
To continuously build the ng app assets being served by the Spring Boot app
gradle ngWatch
Or if you launched the Spring Boot application in Eclipse (as Eclipse will be
using the bin/
folder vs default gradle build/
):
gradle ngWatch -PngBuildDir=bin/static