简体   繁体   English

Spring 引导微服务嵌入式 tomcat 与外部 tomcat

[英]Spring Boot microservices Embedded tomcat vs External tomcat

I am building microservices(approx 15 to microservices) project for huge organization, I wants to know is it recommended to go for external tomcat with war file or just use the embedded tomcat of spring boot with jar file. I am building microservices(approx 15 to microservices) project for huge organization, I wants to know is it recommended to go for external tomcat with war file or just use the embedded tomcat of spring boot with jar file. Also I am facing issue after building my project on jenkins how to copy the file from jekins server to my server and run the file there and create and automatic build and deployment pipeline ie everytime I push the code it should be automatically deployed.在 jenkins 上构建我的项目后,我也面临问题如何将文件从 jekins 服务器复制到我的服务器并在那里运行文件并创建和自动构建和部署管道,即每次我推送代码时它应该自动部署。

You need to identify what compels you to go for external tomcat deployment.您需要确定是什么迫使您使用 go 进行外部 tomcat 部署。 As SpringBoot provides out of box facility to deploy within the container, it is not required to go for external tomcat deployment.由于 SpringBoot 提供了在容器内部署的开箱即用工具,因此对于外部 tomcat 部署,不需要 go。

Besides, if you are going for many microservices, it will be good to have with built in springboot with embeded tomcat.此外,如果您要使用许多微服务,最好使用带有嵌入式 tomcat 的内置 springboot。 Springboot also provides the facility to use undertow or jetty. Springboot 还提供了使用 undertow 或 jetty 的工具。 I would recommend to use SpringBoot with either embeded tomcat or undertow with docker container for more flexibility.我建议将 SpringBoot 与嵌入式 tomcat 或与 docker 容器一起使用,以获得更大的灵活性。

It will be good if you provide the issues you are facing.如果您提供您面临的问题,那将是一件好事。 You can check the below link for reference.您可以查看以下链接以供参考。 https://dzone.com/articles/spring-boot-with-external-tomcat https://dzone.com/articles/spring-boot-with-external-tomcat

I didn't encourage until today companies using Spring Boot and deploying in an external Tomcat.直到今天我才鼓励公司使用 Spring 引导并部署在外部 Tomcat 中。

If there is no requirements from your Infrastructure department, I would go with the embedded tomcat.如果您的基础设施部门没有要求,我会使用 go 和嵌入式 tomcat。

JARs vs WARs JARs 与战争

I think both have their use cases, like a car vs a truck.我认为两者都有其用例,例如汽车与卡车。

Getting started with jar files is definitely easier, it's provided out of the box.开始使用jar文件肯定更容易,它是开箱即用的。 However, using war files in a tomcat has a few perks too:但是,在 tomcat 中使用war文件也有一些好处:

  • You can use the "manager" UI to update/redeploy a webapp easely您可以使用“管理器”UI 轻松更新/重新部署 web 应用程序
  • You can monitor server status, inspect sessions, basically have a look under the hood您可以监视服务器状态,检查会话,基本上可以看看幕后
  • You can deploy/update multiple wars independently, which might be handy for larger project您可以独立部署/更新多个战争,这对于大型项目可能很方便

...but there is definitely some learning curve to set things up, and it feels a bit...old. ...但是设置起来肯定有一些学习曲线,而且感觉有点...老了。 So it's up to you if you want an easy "jar car" or a whole "servlet container truck".因此,如果您想要一个简单的“罐车”或整个“servlet 集装箱卡车”,这取决于您。 ...or you can also have multiple cars. ...或者您也可以拥有多辆汽车。 ;) Each has ups and downs. ;) 每个人都有起起落落。

Pipelines管道

Like for any other topic, there are very different ways to achieve this.与任何其他主题一样,有很多不同的方法可以实现这一目标。 If you use an extern tomcat, you may configure a "script" user and deploy it like this (or similar):如果您使用外部 tomcat,您可以配置“脚本”用户并像这样(或类似)部署它:

curl -u username:pwd -d path=/something -d war=file:target/someWar.war https://someurl.com/manager/deploy

...or you can go the other way round and create Docker images, or cloud-init VMs or whatever. ...或者您可以反过来创建 go 并创建 Docker 映像或 cloud-init VM 或其他任何东西。 Or just a shell script to stop it remotely, upload it and start it.或者只是一个 shell 脚本来远程停止它,上传并启动它。

Depending on your situation, the know how of your team mates, etc, one or the other may be easier.根据您的情况,您的队友等的专业知识可能会更容易。

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

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