• 创建 Spring Boot

    创建 Spring Boot

    如何创建Spring Boot应用并导入Jenkins X

    如果你在开发基于Java的微服务,那么,你可能正在用流行的Spring Boot。

    你可以利用Spring Boot Initializr创建Spring Boot应用,然后通过执行命令 jx import 来导入Jenkins X。

    然而,另外一个快速自动化的方式,是通过执行 jx create spring 命令实现:

    1. $ jx create spring -d web -d actuator

    参数 -d 允许你指定希望添加到 Spring Boot 应用中的依赖。

    我们强烈建议你总是包括依赖 actuator 到你的 Spring Boot 应用中,它可以为 Liveness and Readiness probes 提供健康检查。

    命令 jx create spring 的步骤如下:

    • 在子目录中创建一个新的 Spring Boot 应用
    • 把你的源码加入到git库中
    • 在 git 服务,例如 GitHub,添加 git 远程库
    • 推送代码到 git 远程库
    • 添加默认的文件:
      • Dockerfile 把你的应用构建为 docker 镜像
      • Jenkinsfile 实现 CI / CD 流水线
      • 在 Kubernetes 中通过 helm chart 运行你的应用
    • 为你的 Jenkins 在 git 远程库上注册 webhook
    • 为你的 Jenkins 添加 git 库
    • 首次触发流水线