Home Angular JS and Springboot integration using rest api
Reply: 2

Angular JS and Springboot integration using rest api

Ruchita J
Ruchita J Published in 2018-01-12 21:49:33Z

I am trying to connect two different small applications. Client application is in Angular 5 and Server side is in Spring boot. Angular 5 application works fine on localhost:4200/register port and Spring boot (Server Side) works fine on port localhost:8080/api/demo.

For integration I have used added a proxy.conf.json file in Angular Application. I have updated package.json script also. Followed the instruction on the website: http://javasampleapproach.com/java-integration/integrate-angular-4-springboot-web-app-springtoolsuite#5_Import_Angular4_client_project_to_SpringToolSuite.

Both the projects are in same workspace.

Angular project files added for integration---> proxy.conf.json :

    "api": {
        "target": "http://localhost:8080",
        "secure": false
      "name": "my-new-project",
      "version": "0.0.0",
      "license": "MIT",
      "scripts": {
      "ng": "ng",
      "start": "ng serve --proxy-config proxy.conf.json",
      "build": "ng build",
      "test": "ng test",
      "lint": "ng lint",
      "e2e": "ng e2e"

SPRINGBOOT ---> Rest API: package com.example.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

public class DemoController {

    //@RequestMapping(method = RequestMethod.GET, value = "/api/demo")
    public String demo() {
        return "Hello Demo Application";


So I want to access url like localhost:4200/api/demo (localhost:4200 is angular and "api/demo" comes from Springboot ) Can someone please guide me here in the right direction. TIA

JaisAnkit Reply to 2018-01-12 22:08:02Z

As said in docs either set server.port as system property using command line option to jvm --server.port=8090 or add application.properties in /src/main/resources/ with

server.port = 4200

Dhiraj Ray
Dhiraj Ray Reply to 2018-01-14 10:09:49Z

The above configuration looks fine.Make sure to use ng serve --proxy-config proxy.conf.json or npm start to start the angular app and the context for spring boot app is http://localhost:8080. Also, you can find a working example here - Spring Boot Angular 5 Proxy Config

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.356839 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO