我正在尝试使用Spring (第5版)&角5制作一个基于web的应用程序.我的想法是,Spring将提供restful web服务&Range5将调用这些web服务并在客户端管理用户界面。
我的问题是,我是否需要在服务器上运行两个单独的web应用程序(一个用于UI,一个用于web服务)?如果是-什么将是web服务器的角5应用程序?如果没有-我们如何将角5与spring集成?有谁能给我提供一个工作示例--如何用角5实现spring?在单一的web服务器上运行这两个应用程序是很好的实践吗?你有什么建议?
任何帮助都是非常感谢的..。提前谢谢..。
发布于 2018-05-23 07:27:40
1)在服务器上运行不需要2个web应用程序。
2)构建角项目,并将所有文件从角项目的dist目录复制到spring项目的WebContent目录。
3)
按照以下步骤在单个服务器上使用Angular5运行SPRING。
1.Create normal Dynamic web project.
2.Add all dependancy required for spring or user maven pom.xml
3.Open CMD, navigate to angular2 application. Hit command
'npm install'
and then
'ng build'
or use 'ng build --prod' for production build.
this command will create a “dist” folder, copy all files including all folders.
4. Paste those files and folders into 'WebContent' directory.
5. Last thing, you need to change basehref=”./” in index.html.现在,您已经准备好运行服务器,或者您可以部署war文件,并将其与tomcat或其他服务器一起服务。
我已经找到了包含Spring与角2:https://github.com/rakshitshah94/Angular2-SpringBoot-Example的完整工作示例的git。
4)不,在Spring项目中包含角构建文件不能说是很好的实践。因为每次更改角时,都必须重新构建Spring文件,并将其再次部署到war服务器。
发布于 2018-05-23 07:31:25
将Spring4MVC与角2集成在一台服务器上。请参考这个link。它的工作角度也是5
https://stackoverflow.com/questions/50481885
复制相似问题