简体   繁体   中英

Deploy Angular 5 and spring boot applications on same tomcat at different ports

I am developing a small project where I have Springboot java application and Anagular 5 application. I want to deploy them on one tomcat. running each on diffrent ports.

Application Flow should be like this: 1) Some external service calls Java application with some headers. Springboot java application should read the headers put them in cookie and forward the request to Angular application. 2)Angular application reads the headers from the cookie and communicates to another application(Hosted somewhere else) with API calls.

What I tried: I am able to deploy Spring boot application on tomcat. For angular deployment I am copy pasting the dist folder into webapp.

What is question about: I wanted them to run at a time on tomcat on defferent ports so.

external application --calls-> java application(say running on localhost:8080)-----redirect from localhost:8080 to ----> Angular application(say running on localhost:8081).

in moment your are delegating servlet container to a provided one, all spring properties concerning an "embedded" container will be simply ignored. This is the case of server.port property.

Maybe it's a client/company constraint BUT using Spring Boot project this way makes you loose big part of its benefits: Raising serverless apps ready to be horizontaly scaled :(

Spring Boot keeps the possibility to let your static resources in the apps whitout loosing the ability to run the embedded container; by building an executable war.

Tip: To do that, just change the packaging from .jar to .war .

Hope was helpful :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM