如何在Spring Boot上部署多个服务?

我必须编写后端的传递服务。 我想为需要了解详细交付任务的供应商提供一项服务。 而且我也希望为顾客提供服务,从哪里可以订购。 所以这两个服务必须相互交谈。 我读了一些关于Docker和Spring Cloud的内容,但是我不确定它是否能完成这项工作。

问题:如何在单个应用程序中部署2个服务?

你能否澄清一下这两个服务之间的对话是什么意思? 你想如何沟通? RESTful API? 他们共享一个数据库吗? 这似乎是一个复杂的解决scheme,为您的使用情况。

如果你想让两个可以互相沟通的微服务站起来,你可以用Docker Compose来支持这两个应用程序。

使用最新版本的Docker Compose,你可以做这样的事情

version: '3' services: supplier: build: path/to/supplier/dockerfile image: name-this-image ports: # whatever you defined for this spring boot application (example below) - "8080:8080" networks: main: customer: # do something here similar to above for the other application networks: main: