简体   繁体   English

在服务器上部署角度2的Spring MVC

[英]Spring mvc with angular 2 deployment on server

I want to create a Spring MVC rest application for web browser, android and ios For web browser, I am using angular2 and my web server is apache tomcat. 我想为Web浏览器,Android和ios创建一个Spring MVC rest应用程序。对于Web浏览器,我正在使用angular2,而我的Web服务器是apache tomcat。 So I am confused that I need to put the angular code inside my Spring mvc appllication project directory or create a separate instance for angular.If I have to create separate instance for both then how I will deploy angular code to the tomcat server. 所以我很困惑,我需要将角度代码放入Spring mvc应用程序项目目录中或为angular创建一个单独的实例。如果我必须为这两个都创建单独的实例,那么我将如何将角度代码部署到tomcat服务器。

You can do the both. 两者都可以。

If you want to put the angular2 files to the tomcat then look here . 如果要把angular2文件放到tomcat中, 请看这里 This is might not straight forward. 这可能不是直接的。

If you want to deploy separately, I mean server(spring REST) and client(angular2) then angular2 app can deploy using the ng command or any web server like apache, nginx. 如果要单独部署,我的意思是服务器(春季REST)和客户端(angular2),那么angular2应用可以使用ng命令或任何Web服务器(如apache,nginx)进行部署。 You can look here for example 你可以看这里例如

You can do that in any of the ways. 您可以通过任何方式做到这一点。


But with a SPA + REST technology stack, I prefer separating front end and back end with rest api because static resources are best served from front-server. 但是,使用SPA + REST技术堆栈,我更喜欢使用rest api分离前端和后端,因为最好从前端服务器提供静态资源。 Since Front-End servers (eg nginx,apache2) are very powerful and since you can use Cache for static resources, you can manage with a single deployment of your static resources (which should be all HTML content, JS, CSS, Images). 由于前端服务器(例如nginx,apache2)非常强大,并且您可以将Cache用于静态资源,因此您可以对静态资源(应该是所有HTML内容,JS,CSS,图像)进行一次部署进行管理。

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

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