Web应用程序(春,角,咕噜,Maven的,Tomcat)的同时运行咕噜和Tomcat服务器 [英] Web App (Spring, Angular, Grunt, Maven, Tomcat) running both grunt and tomcat servers

查看:177
本文介绍了Web应用程序(春,角,咕噜,Maven的,Tomcat)的同时运行咕噜和Tomcat服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

行,所以我一直在阅读一些其他堆栈问题,并试图在没有多少运气拼凑这一点。基本上,我的做法是,我目前有多个分项目一个项目。我基本上有以下几点:

OK so I've been reading several of the other stack questions and trying to piece this together without much luck. Basically my approach is that I currently have one project with multiple sub-projects. I basically have the following:

root
|----backend
|----|----src
|----|----|----main
|----|----|----|----java (individual java files not shown)
|----|----|----|----resources
|----|----|----|----|----META-INF
|----|----|----|----|----|----applicationContext.xml
|----|----|----|----webapp
|----|----|----|----|----WEB-INF
|----|----|----|----|----|----web_servicesConfig.xml
|----|----|----|----|----|----web.xml
|----|----pom.xml
|----deploy
|----|----src
|----|----|----main
|----|----|----|----resources (properties files for tomcat)
|----|----pom.xml
|----frontend
|----|----app
|----|----|----angular files
|----|----bower_components
|----|----|----bower files
|----|----bower.json
|----|----Gruntfile.js
|----|----pom.xml

好希望这是对文件结构不够清晰。我打算使用Maven的咕噜-插件,所以我可以运行在前台我咕噜命令。前端是基本相同的设置哟角产生,或者是至少的目标。简单地部署建立Tomcat和后端保持弹簧4 RESTful服务/ API。

Ok hopefully that's clear enough on the file structure. I'm planning to use the maven-grunt-plugin so I can run my grunt commands on the frontend. The front end is basically the same setup as yo angular produces or that's at least the goal. Deploy simply sets up tomcat, and backend holds the Spring 4 restful services/api.

确定,所以这是是我很困惑,并寻求帮助。我不知道如何让前端与后端正常工作。基本上我在想,如果有一种方法来告诉Maven来启动Tomcat,并咕噜服务器的开发模式,这样我可以同时使用其功能,以快速开发我的项目,然后最小文件拉入战争的生产版本。我想我无法弄清楚如何使一切都很好地一起玩。我检查了这个问题,哪种谈论它,但我仍然困惑:

OK so this is were I'm confused and looking for help. I don't know how to get the frontend to work correctly with the backend. Basically I was wondering if there's a way to tell maven to start the Tomcat, and Grunt servers in dev mode so that I can use both of their features to quickly develop my project, and then pulling the min files into the war for the production build. I guess I can't figure out how to make everything play nicely together. I checked out this question which kind of talks about it but I'm still confused:

<一个href=\"https://stackoverflow.com/questions/23920508/how-to-deploy-angularjs-app-and-spring-restful-api-service-on-the-same-domain-se\">How部署同一个域/服务器应用程序AngularJS和Spring宁静的API服务?

我很乐意,解决了如何使用Maven和Tomcat,春天,angularjs和咕噜教程任何联系......也鲍尔这样我就可以用它为我的前端包管理。我读过几个例子,并已看到许多关于如何使用的弹簧与Java EE和jsp讨论。或者用摇篮做一些事情,我想......但没有完全像我试图。

I would love any links to tutorials that address how to use Maven with tomcat, spring, angularjs, and grunt...also bower so I can use it for my frontend package management. I've read several examples, and have seen many discussing on how to use spring with Java EE and jsp. Or using Gradle to do some things I want...but nothing exactly like I'm attempting.

当然,如果这是一个不好的做法让我知道。基本上,我想我的子项目的分离尽可能同时仍然允许开发人员导入/从一个POM文件运行。

Of course if this is a bad approach let me know. Basically I want to make my subproject as separated as possible while still allowing the developer to import/run from one pom file.

推荐答案

从你的问题我挖了只有两个问题

from your question i digged up only two questions


  1. 怎么办继续咕噜开发/亭子+ tomcat的

  2. 如何部署生产

我已经选择了该解决方案 - 因为你已经在使用 API 沟通客户&LT; - &GT;服务器 - 是的独立的全部两个项目

1 - Continues Developing

The solution i have chosen for that - since you already use api to communicate client <-> server- is to separate completely the two projects.

所以,这是什么意思?
对我来说是有两个不同的存储库。一个用于客户端,一个是服务器
之一时,此方法你会得到一些好处:

So what does it mean? for me is to have two different repositories. One for client, One for Server one this way you get few benefits:


  • 分割的项目工作(前端\\服务器端)

  • 更容易维护

  • 如果你想支持API只为一个例子移动应用等。

可是 - ?他们如何沟通,同时发展

这是一个很好的问题:
一个解决方案是运行在本地主机上2服务器并行即 MVN清洁的tomcat:运行-P yourprofile;咕噜服务器

This is a good question: one solution is to run two server on localhost in parallel i.e mvn clean tomcat:run -P yourprofile; grunt server

但是 - 我会得到跨域如果我尝试从客户端从不同的端口访问服务器端
你是对的。在这里你会得到咕噜及其插件的帮助。抢副本咕噜连接代理

怎么样这个插件,它让你问咕噜服务器的API,但实际上咕噜是问Tomcat服务器来回答充当咕噜服务器和Tomcat服务器之间的中间件尼斯(后面阶段ofcourse)

what nice about this plugin that it act as a middleware between grunt server and tomcat server so you ask grunt server for the api but actually grunt is asking tomcat server to answer on that (behind stage ofcourse)

我想这是个人喜好的问题的问题。但我觉得战争文件非常大一遍又一遍做上传(即使是能够把所有你的Tomcat应用程序之间共享LIB)。我想出了解决的办法是做了部署混帐。

i guess this is a matter of personal favor question. but i find the war file extremely big to do upload again and again (even if are able to share lib between all of your tomcat app). The solution i came up with is to do deploy over git.

确定,但我有一个大的战争文件。我该怎么办呢?

对于我来说我使用的是部署脚本我在bash写道。它做什么

For me i use a deploy script i wrote in bash. what it does


  1. 标签电流源

  2. 运行MVN清洁套装战争:爆炸-P你-PROD-轮廓(这将运行测试和集成测试以及)

  3. 与上面的命令,你得到所有符合项目的文件在一个地方。而不是一个大的战争文件。

  4. 所有这些文件(和内路径)复制到外的文件夹中(我用另一个仓库维修部署过了Git。所以basicly我有3个仓库。一个客户端源服务器源之一,一个用于服务器的二进制文件。)

  5. 操作前4确保从中删除所有文件和文件夹(除了git的东西)

  6. 4后做混帐添加-A

  7. git的承诺-a -m新产版X

  8. 您可以标记一些标签之前并允许恢复过去的code的简单的方法,如果有新的生产的一个严重错误
  9. 之后
  10. 在服务器上运行的远程命令a.stop服务器b.pull从二进制库c中的最后一个变化。再次运行服务器。

  11. 对我来说,我所做的是一个外部文件夹中的Tomcat应用程序之间的符号链接(二进制库),因此

希望这会给你一些方向,

Hope this will give you some directions,

最好成绩,
橡树

Bests, Oak

这篇关于Web应用程序(春,角,咕噜,Maven的,Tomcat)的同时运行咕噜和Tomcat服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆