Skip to content

chriswhite199/spring-boot-angular2-stomp

Repository files navigation

Spring Boot, Websocket, Stomp & Angular

Refactor of the Spring Websocket Guide using STOMP to use Angular 2

Checkout this project, or to re-create from scratch:

  1. Create new Spring boot initializer project at https://start.spring.io/
    • Add Websocket, Lombok & Devtools Dependencies
  2. Unpack project to workspace
  3. Add code as per the Spring Websocket Guide, with some modifications
    • Condensed Greeting.java and HelloMessage.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
      

Running

  1. Run bootRun Gradle task to launch server (builds ng app too)

     gradle bootRun
    
  2. Point a Browser at http://localhost:8080/

Continuous ng Build

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

References

About

Refactor of the Spring Websocket Guide using STOMP to use Angular 2

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published