generator-springboot:自动生成SpringBoot代码


生成SpringBoot微服务的Yeoman生成器。

特点:

  • 采用jar类型打包的SpringBoot REST API
  • CORS配置
  • Swagger UI集成
  • Spring Data JPA集成,可选择MySQL、Postgresql、MariaDB等数据库
  • 支持Flyway或Liquibase数据迁移
  • SpringBoot Actuator 配置
  • TestContainers集成
  • JUnit 5
  • 应用、ELK、Prometheus、Grafana的Docker配置
  • Localstack配置
  • Jenkinsfile
  • GitHub动作配置
  • SonarQube、Google-java格式的静态分析工具配置


安装:

> git clone https://github.com/sivaprasadreddy/generator-springboot.git
> cd generator-springboot
> npm install -g yo
> npm install 
> npm link
> yo springboot


生成带有 CRUD 操作的 REST API
您可以使用以下命令生成带有 CRUD 操作的 REST API:
从生成的项目文件夹中运行以下命令:

yo springboot:controller Customer --base-path /api/customers

这将生成:

  • JPA实体
  • Spring Data JPA 存储库
  • 服务
  • 具有 CRUD 操作的 Spring MVC REST 控制器
  • REST 控制器的单元和集成测试
  • Flyway 或 Liquibase 迁移以创建表

既然有了 JHipster,为什么还要另一个生成器呢?
JHipster是一个了不起的SpringBoot应用程序生成器,有很多很多很酷的功能。然而,JHipster的某些功能并不适合我的喜好,例如:

  • 我喜欢jar包
  • 我喜欢使用spring-boot-starter-*而不是配置单个库
  • 我喜欢有一个选项来生成没有spring-security的应用程序
  • 比起Liquibase,我更喜欢Flyway
  • 我喜欢只有最低限度的必要配置,即没有AsyncConfiguration、LocaleConfiguration、CacheConfiguration、Logstash Logging等。
  • 我喜欢.properties而不是.yml