npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-springboot

v0.1.6

Published

A Yeoman generator for generating SpringBoot microservices

Downloads

41

Readme

generator-springboot

The Yeoman generator for generating Spring Boot microservices.

Prerequisites

  • Node 18+
  • JDK 17+

Installation

$ npm install -g yo
$ npm install -g generator-springboot

How to use?

Run the following command and answer the questions:

$ yo springboot

Features

The generator-springboot generates a Spring Boot application with the following features configured:

  • Spring Boot project with Maven and Gradle support
  • Spring Data JPA integration with an option to select databases like MySQL, Postgresql, MariaDB.
  • Flyway and Liquibase database migration support.
  • Spring Cloud AWS support with LocalStack configuration.
  • CORS configuration
  • Swagger UI Integration
  • SpringBoot Actuator configuration
  • Testcontainers based Testing and Local dev mode setup
  • DockerCompose configuration for application, ELK, Prometheus, Grafana
  • GitHub Actions Configuration
  • Dockerfile
  • Jenkinsfile
  • SonarQube and JaCoCo based static analysis tools configuration
  • Code formatting using Spotless and google-java-format
  • JUnit 5

Generate a SpringBoot Microservice

After installing the generator-springboot, you can generate a new Spring Boot application as follows:

$ yo springboot
Generating SpringBoot Application
? What is the application name? blog
? What is the default package name? com.sivalabs.blog
? Which type of database you want to use? Postgresql
? Which type of database migration tool you want to use? FlywayDB
? Select the features you want? ELK Docker configuration, Prometheus, Grafana Docker configuration, Localstack Docker configuration
? Which build tool do you want to use? Maven
    force blog/.yo-rc.json
   create blog/mvnw
   create blog/mvnw.cmd
   create blog/.gitignore
   create blog/.mvn/wrapper/maven-wrapper.jar
   create blog/.mvn/wrapper/maven-wrapper.properties
   create blog/pom.xml
   create blog/Dockerfile
   create blog/Jenkinsfile
   create blog/lombok.config
   create blog/sonar-project.properties
   create blog/README.md
   create blog/.github/workflows/maven.yml
   create blog/src/main/resources/db/migration/postgresql/V1__01_init.sql
   create blog/docker/docker-compose.yml
   create blog/docker/docker-compose-app.yml
   create blog/docker/docker-compose-monitoring.yml
   create blog/config/prometheus/prometheus.yml
   create blog/config/grafana/provisioning/dashboards/basic-dashboard.json
   create blog/config/grafana/provisioning/dashboards/dashboard.yml
   create blog/config/grafana/provisioning/dashboards/jvm-micrometer_rev10.json
   create blog/config/grafana/provisioning/datasources/datasource.yml
   create blog/docker/docker-compose-elk.yml
   create blog/config/elk/logstash.conf
   create blog/.localstack/01_init.sh
   create blog/src/main/java/com/sivalabs/blog/Application.java
   create blog/src/main/java/com/sivalabs/blog/config/WebMvcConfig.java
   create blog/src/main/java/com/sivalabs/blog/config/SwaggerConfig.java
   create blog/src/main/java/com/sivalabs/blog/config/ApplicationProperties.java
   create blog/src/main/java/com/sivalabs/blog/config/Initializer.java
   create blog/src/main/java/com/sivalabs/blog/config/GlobalExceptionHandler.java
   create blog/src/main/java/com/sivalabs/blog/config/logging/Loggable.java
   create blog/src/main/java/com/sivalabs/blog/config/logging/LoggingAspect.java
   create blog/src/main/java/com/sivalabs/blog/exception/ResourceNotFoundException.java
   create blog/src/main/java/com/sivalabs/blog/model/response/PagedResult.java
   create blog/src/main/java/com/sivalabs/blog/utils/AppConstants.java
   create blog/src/main/resources/application.properties
   create blog/src/main/resources/application-local.properties
   create blog/src/main/resources/logback-spring.xml
   create blog/src/test/java/com/sivalabs/blog/ApplicationIntegrationTest.java
   create blog/src/test/java/com/sivalabs/blog/SchemaValidationTest.java
   create blog/src/test/java/com/sivalabs/blog/common/ContainersConfig.java
   create blog/src/test/java/com/sivalabs/blog/common/AbstractIntegrationTest.java
   create blog/src/test/java/com/sivalabs/blog/TestApplication.java
   create blog/src/test/java/com/sivalabs/blog/SqsListenerIntegrationTest.java
   create blog/src/test/resources/application-test.properties
   create blog/src/test/resources/logback-test.xml

No change to package.json was detected. No package manager install will be executed.
Picked up JAVA_TOOL_OPTIONS:  -Xmx3489m
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.sivalabs.blog:blog >-----------------------
[INFO] Building blog 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- spotless:2.39.0:apply (default-cli) @ blog ---
[INFO] Index file does not exist. Fallback to an empty index
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/config/SwaggerConfig.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/config/GlobalExceptionHandler.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/config/logging/LoggingAspect.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/exception/ResourceNotFoundException.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/model/response/PagedResult.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/common/ContainersConfig.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/common/AbstractIntegrationTest.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/SchemaValidationTest.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/TestApplication.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/SqsListenerIntegrationTest.java
[INFO] Spotless.Java is keeping 17 files clean - 10 were changed to be clean, 7 were already clean, 0 were skipped because caching determined they were already clean
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.454 s
[INFO] Finished at: 2023-10-25T16:57:22Z
[INFO] ------------------------------------------------------------------------
==========================================
Your application is generated successfully
  cd blog
  > ./mvnw spring-boot:run
==========================================

Generate REST API with CRUD operations

You can generate REST API with CRUD operation using the following command:

IMPORTANT: You should run the following command from within the generated project folder.

$ cd blog
$ yo springboot:controller Customer --base-path /api/customers

This sub-generator will generate the following:

  • JPA entity
  • Spring Data JPA Repository
  • Service
  • Spring MVC REST Controller with CRUD operations
  • Unit and Integration Tests for REST Controller
  • Flyway or Liquibase migration to create table
$ yo springboot:controller Customer --base-path /api/customers
Generating JPA entity, repository, service and controller
EntityName: Customer, basePath: /api/customers
    force .yo-rc.json
   create src/main/java/com/sivalabs/blog/entities/Customer.java
   create src/main/java/com/sivalabs/blog/exception/CustomerNotFoundException.java
   create src/main/java/com/sivalabs/blog/mapper/CustomerMapper.java
   create src/main/java/com/sivalabs/blog/model/query/FindCustomersQuery.java
   create src/main/java/com/sivalabs/blog/model/request/CustomerRequest.java
   create src/main/java/com/sivalabs/blog/model/response/CustomerResponse.java
   create src/main/java/com/sivalabs/blog/repositories/CustomerRepository.java
   create src/main/java/com/sivalabs/blog/services/CustomerService.java
   create src/main/java/com/sivalabs/blog/web/controllers/CustomerController.java
   create src/test/java/com/sivalabs/blog/web/controllers/CustomerControllerTest.java
   create src/test/java/com/sivalabs/blog/web/controllers/CustomerControllerIT.java
   create src/test/java/com/sivalabs/blog/services/CustomerServiceTest.java
   create src/main/resources/db/migration/postgresql/V2__create_customers_table.sql

No change to package.json was detected. No package manager install will be executed.
Picked up JAVA_TOOL_OPTIONS:  -Xmx3489m
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.sivalabs.blog:blog >-----------------------
[INFO] Building blog 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- spotless:2.39.0:apply (default-cli) @ blog ---
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/exception/CustomerNotFoundException.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/model/query/FindCustomersQuery.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/model/request/CustomerRequest.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/entities/Customer.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/mapper/CustomerMapper.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/services/CustomerService.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/main/java/com/sivalabs/blog/web/controllers/CustomerController.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/web/controllers/CustomerControllerIT.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/web/controllers/CustomerControllerTest.java
[INFO] Writing clean file: /workspace/generator-springboot/blog/src/test/java/com/sivalabs/blog/services/CustomerServiceTest.java
[INFO] Spotless.Java is keeping 28 files clean - 10 were changed to be clean, 1 were already clean, 17 were skipped because caching determined they were already clean
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.246 s
[INFO] Finished at: 2023-10-25T16:59:48Z
[INFO] ------------------------------------------------------------------------

Local Development Setup

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

Releasing a new version

Before publishing a new release, make sure to update the version number in package.json updated.

$ npm login
$ npm publish

License

The generator-springboot is an Open Source software released under the MIT Licence