I am trying to integrate Angular 2 application with Java Spring Boot backend. For the moment, I place my Angular 2 files under src/main/resources/static
(meanin
I had a similar issue, after some frustrating researches I solved the 404 error thanks to this. The order of imports matters.
Hope it helps someone.
The reason of this error was that I used Angular Tour of Heroes applcation as a basis for mine, and I did not remove the dependency
"angular-in-memory-web-api": "~0.2.4",
and InMemoryWebApiModule
from app.module.ts. Because of this all requests were intercepted by InMemoryWebApiModule (despite I did not call it directly as described in Tour of Heroes Tutorial), that's why I did not see any XMLHttpRequests in 'Network' tab of the browser debugger.
After I have removed the dependency from package.json
and node_modules
directory, it started working normally, however, I had to change the service code to parse Json directly to TypeScript objects like this:
getLanguages(): Promise<Language[]> {
return this.http.get(this.langUrl)
.toPromise()
.then(response => response.json() as Language[])
.catch(this.handleError);
}
This is a newbie mistake, but I hope this post will save a couple of hours of research to someone.
In Chrome or Firefox you can see the HTTP requests and responses your application executes (just hit F12 and select the Network tab). Since you are saying it is working with your browser or Postman, you can compare both requests and should quickly find the difference.