如何为 Spring 引导项目设置 Google 云计算引擎?

How to setup Google Cloud Compute Engine for Spring Boot project?

我读了很多文章,看过很多 YouTube 视频,但没有解决我的问题。我想知道在Google云端购买主机需要经过什么流程?它是免费的还是我们需要付费?除此之外,如果我想部署我的 Spring Boot 项目,那么我们需要执行什么操作?

写在 How to setup Google Cloud Compute Engine for Spring Boot project? 上的一篇非常好的文章。

According to this article you will have to do 2 activities.

  1. Setup Billing Information
  2. Setup the execution environment

第一步,您必须signup/login使用Google账户https://console.cloud.google.com. Here it is mandatory to provide your debit/card details along with the cvv and you will have to pay 1 Rupee. For verification purpose, you need to upload one of the governement id proof like UID/Driving Licence/Passport and your debit/credit photo. After submiting the form, it will take less than 4 hours to activate your cloud account. After activating your account you need to create your machine and based on the machine type you will be charged but make sure for 1 year Google will not charge you anything. Google will give you 0 to spend on Google Cloud Platform products during your first 12 months. For price details you can visit here

在第二步中,您需要安装所需的软件,如Java、Git、 Maven、PM2 等。为了便于部署,您可以使用 PM2,它是 JavaScript 运行时 Node.js 的进程管理器。在你的 Spring Boot 项目根目录中,你需要创建一个配置文件 server.sh 文件,其中包含 mvn spring-boot:run。使用 chmod +x server.sh 使该文件可执行。要启动服务器,您只需键入 pm2 restart server。启动服务器后,您甚至可以使用 pm2 logs.

检查日志

For better visibility & understanding I will recommend to read this complete article.