Web application example of Microservices using Spring Boot
Firstly, checking whether or not you have ‘Node.js‘ installed, by command: node -v & npm -v. If the command goes unrecognized, we must install ‘NodeJS‘. Go to: nodejs.org. Download NodeJS installer, the tutorial uses version: 10.4.0 Current. We got a ‘node-v10.4.0-x64.msi‘ file, double click on it and follow the guides to setup NodeJS.
Open cmd, checking NodeJS by commandline: node -v & npm -v
Using commandline npm install -g @angular/cli
Check Angular-CLI after setup by commandline ng -version
Please refer Spring boot module.
Run below command to generate initial Angular 6 client project:
ng new Angular6-client
Start angular6-client project by cmd npm start
Check angular application on http://localhost:4200
Angular client calls SpringBoot RestAPIs Angular6-Client and SpringBoot server work independently on ports 4200 and 8080. The client at 4200 will proxy any /api requests to the SpringBoot server at port 8080.
– Create a file proxy.conf.json under project angular6-client folder with content:
{ "/test-account": { "target": "http://localhost:8080", "secure": false } }
– Edit package.json file for start script:
"scripts": { "ng": "ng", "start": "ng serve --proxy-config proxy.conf.json", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" },
– Build and run the SpringBoot project at port 8080. And restart angular6-client at port 4200
- Make a request http://localhost:4200/test-account