简体   繁体   English

在同一tomcat的不同端口上部署Angular 5和Spring Boot应用程序

[英]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. 我正在开发一个小项目,其中有Springboot Java应用程序和Anagular 5应用程序。 I want to deploy them on one tomcat. 我想将它们部署在一个tomcat上。 running each on diffrent ports. 在不同的端口上运行每个。

Application Flow should be like this: 1) Some external service calls Java application with some headers. 应用程序流应如下所示:1)一些外部服务使用一些标头调用Java应用程序。 Springboot java application should read the headers put them in cookie and forward the request to Angular application. Springboot Java应用程序应读取将其放在cookie中的标头,并将请求转发给Angular应用程序。 2)Angular application reads the headers from the cookie and communicates to another application(Hosted somewhere else) with API calls. 2)Angular应用程序从cookie读取标头,并通过API调用与另一个应用程序(托管在其他地方)通信。

What I tried: I am able to deploy Spring boot application on tomcat. 我尝试过的事情:我能够在tomcat上部署Spring boot应用程序。 For angular deployment I am copy pasting the dist folder into webapp. 对于角度部署,我将粘贴dist文件夹复制到webapp中。

What is question about: I wanted them to run at a time on tomcat on defferent ports so. 问题是什么:我希望它们一次在不同端口的tomcat上运行。

external application --calls-> java application(say running on localhost:8080)-----redirect from localhost:8080 to ----> Angular application(say running on localhost:8081). 外部应用程序--calls-> java应用程序(例如在localhost:8080上运行)-----从localhost:8080重定向到----> Angular应用程序(例如在localhost:8081上运行)。

in moment your are delegating servlet container to a provided one, all spring properties concerning an "embedded" container will be simply ignored. 当您将servlet容器委派给提供的容器时,与“嵌入式”容器有关的所有spring属性将被忽略。 This is the case of server.port property. 这是server.port属性的情况。

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项目的客户/公司约束,但这种方式使您失去了很大的优势:提升无服务器应用程序的水平缩放能力:(

Spring Boot keeps the possibility to let your static resources in the apps whitout loosing the ability to run the embedded container; Spring Boot可以使您的应用程序中的静态资源停止运行嵌入式容器的能力。 by building an executable war. 通过建立可执行的战争。

Tip: To do that, just change the packaging from .jar to .war . Tip:为此,只需将包装从.jar更改为.war

Hope was helpful :) 希望是有帮助的:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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