search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Servers

Related article: Angular 2: Scheduler UI with Spring Boot Backend (Java)
Asked by Sergey
2 years ago.

When I start up my Spring Boot application Tomcat server starts up. When I run "npm start" somebody server for Angular 2 starts too. Can I use only one server (only Tomcat) and if it is true now to do that.
Sorry my English.

Answer posted by Dan Letecky [DayPilot]
2 years ago.

With Angular CLI (which uses Webpack) the Angular 2 project needs to be run using "ng serve" (available as "npm run start"/"npm start") during development. That's why the tutorial uses two independent projects and uses a proxy for the Spring Boot backend. You don't have to use the proxy if you point your URLs directly to the Tomcat development server but you need to run both servers.

When you build the production package using "ng build --prod" it will create a folder called "dist" which contains static files that can be deployed to the production server - you can copy those files to the Spring Boot application as static content (https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot). You'll probably want to do that as part of your build process.

You can also package the Angular application as a war file (containing just the static files generated by webpack) and deploy it to the same Tomcat server (at a different location).

Comment posted by Sergey
2 years ago.

I see, thanks. :)

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.