Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bilal.islam committed Sep 21, 2024
0 parents commit f85c0ca
Show file tree
Hide file tree
Showing 108 changed files with 21,247 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Generator SpringBoot
on:
push:
branches:
- '**'
jobs:
build:
name: npm test
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
node_version: [18.x, 20.x]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
- run: npm install
- run: npm test
env:
CI: true
17 changes: 17 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish Docs via GitHub Pages
on:
push:
branches:
- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea/
*.iml
.DS_Store
node_modules/
/testapp
/myservice/
logs/
generators/server/templates/gradle/.gradle/
7 changes: 7 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gitpod/workspace-full

USER gitpod

RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
&& sdk install java 22.3.r17-nik \
&& sdk default java 22.3.r17-nik"
13 changes: 13 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
# and commit this file to your remote git repository to share the goodness with others.

image:
file: .gitpod.Dockerfile

tasks:
- before: npm install -g yo
init: npm install



4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "automatic",
"java.compile.nullAnalysis.mode": "automatic"
}
68 changes: 68 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Change Log

## Version 0.1.5
* Upgrade Spring Boot version to 3.1.5
* Upgraded Maven and Gradle versions
* Implemented best practices to not expose entity
* Upgraded generator dependencies (chai, sinon, etc)
* Supports running application with Java 21 and Spring Boot 3.2.0

## Version 0.1.4
* Upgrade Spring Boot version to 3.1.3
* Upgraded Maven and Gradle versions
* Refine Testcontainers configuration
* Simplify LocalStack configuration
* Removed H2 database config

## Version 0.1.3
* Upgrade Spring Boot version to 3.1.1
* Introduced Testcontainers support for dev mode
* Fixed LocalStack configuration issues
* Upgraded generator dependencies (chai, sinon, etc)
* Upgraded Maven and Gradle versions
* Updated googleJavaFormat configuration.

## Version 0.1.2
* Fixes issue with mysql and mariadb when flyway is selected ([#58](https://github.com/sivaprasadreddy/generator-springboot/issues/58))
* Support Mariadb Sequences ([#59](https://github.com/sivaprasadreddy/generator-springboot/issues/59))
* Support other liquibase formats ([#69](https://github.com/sivaprasadreddy/generator-springboot/issues/69))
* Upgraded SpringBoot to 3.0.2 and other library versions

## Version 0.1.1
* Upgraded SpringBoot to 3.0.0 and other library versions
* Upgraded AWS to 3.0.0-M3, compatible version with SpringBoot 3 which uses AWS 2.0 API
* Tweaked code to get All entries from datasource using pagination
* Supporting developing application in VSCode
* Enhanced support for logback encoder when elk stack is selected
* Fixes issue while generating api and tables when `tablename` contains camelCase([#47](https://github.com/sivaprasadreddy/generator-springboot/issues/47))
* Upgraded liquibase configuration to use Out of the Box format and location

## Version 0.1.0
* Upgraded SpringBoot to 2.7.4 and other library versions
* Fixed code formatting
* Fixed Flyway with MySQL and MariaDB issue

## Version 0.0.10
* Upgraded SpringBoot to 2.6.7 and library versions
* Updated Spring Cloud AWS setup to use new https://awspring.io/ based configuration
* Removed `springfox-boot-starter` and used `springdoc-openapi-ui`
* Added google-java-format support
* Upgraded plugins versions
* Removed Checkstyle, PMD plugins

## Version 0.0.8
* Configured Checkstyle, PMD, SonarQube, google-java-format plugins
* Added Localstack autoconfiguration support

## Version 0.0.7
* Removed support for generation of `config-server` and `service-registry`
* Updated SpringBoot and other libraries version

## Version 0.0.6
* Updated to use testcontainers-spring-boot https://github.com/testcontainers/testcontainers-spring-boot
* Generate Zipkin docker-compose file when Distributed Tracing is selected
* Fixed Flyway/Liquibase db migration script generation issue
* Added tests for sanity check

## Version 0.0.5
* Added support for generating docker-compose yml files for application, ELK, Prometheus, Grafana
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 K. Siva Prasad Reddy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
223 changes: 223 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
# generator-springboot
The Yeoman generator for generating Spring Boot microservices.

## Prerequisites
* Node 18+
* JDK 17+

## Installation
```shell
$ npm install -g yo
$ npm install -g generator-springboot
```

## How to use?
Run the following command and answer the questions:

```shell
$ 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:

```shell
$ 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.

```shell
$ 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

```shell
$ 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

```shell
$ 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.

```shell
$ npm login
$ npm publish
```

## License
The **generator-springboot** is an Open Source software released under the [MIT Licence](https://opensource.org/license/mit/)
Binary file added docs/crud-generation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f85c0ca

Please sign in to comment.