generator-spring-crud-mongo
v1.0.2
Published
> Mongo crud api generator
Downloads
3
Readme
generator-mongo-crud-generator
Mongo crud api generator
Prerequirement
- Java JDK 11 or newer (can be an open-jdk distro)
- Gradle 2+
- NPM
- Yeoman
- Maven 3+
About this package
This package is a spring-boot crud generator that uses mongo as the primary class for object and database mapping. The main goal of this package is to speed up the process of crud operations, which can take some time to implement. By installing this package, it can do all the work by creating the crude operation with just one command. Although this package will do everything for crud operation, the developer must be aware of certain limitations, how to use, install, and initiate the application properties, and how to add some dependencies on both Maven and Gredle that the package cannot handle.
Awareness
This package author use Gradle dependency for test, build the project and Intellij as the code editor. For the project to be processed, some of the below gradle dependency elements must be included:
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation group: 'org.xhtmlrenderer', name: 'flying-saucer-pdf-openpdf', version: '9.1.11'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springdoc:springdoc-openapi-ui:1.6.13'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.guava:guava:31.1-jre'
// Java Bean mapper
//Mapstruct
implementation "org.mapstruct:mapstruct:$mapstructVersion"
annotationProcessor "org.mapstruct:mapstruct-processor:$mapstructVersion"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
******* This is just the gradle that author use be aware that you can modify version or you wish to implement with maven; please want to make sure that the below gradle or maven dependency topics have been install:
- Lombok
- SpringWeb
- MongoData
- MapStruct
- Mongodb
- SpringValidation
***** Warning: The configuration of database have to be define by your own as well.
Installation
First, install Yeoman and generator-spring-jpa-crud-generator using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-spring-crud-mongo
Then generate your new project:
yo spring-crud-mongo
Getting To Know Yeoman
- Yeoman has a heart of gold.
- Yeoman is a person with feelings and opinions, but is very easy to work with.
- Yeoman can be too opinionated at times but is easily convinced not to be.
- Feel free to learn more about Yeoman.
How to use
- Go to your spring boot project directory
- Type in command "yo spring-crud-mongo"
- Provide domain of the project. Ex: com.myapi.com
- Finally, provide module of your crud. Ex: user
*******NOTES: The author use snakeCase as the format when returning the client; therefore you can make your application.properties as "spring.jackson.property-naming-strategy=SNAKE_CASE". Since, in the unit test, the author checking with snake_case strategy, so to make the application test it correctly you can make change in your application.properties to be snake_case or if you wish to use camal_case please change in the unit test to be whatever you wish.
Features
Generation of fully-functional springboot REST API, using:
- Java 11
- Spring-boot 2.2 REST API
- Gredle 2+
Integrations
This generator allows to integrate the springboot REST API with:
- Mongodb
Functionality
The crud generator will deliver the following:
- Generate clean architectural crud using OOP and SOLID concepts.
- ControllerAdvise implementation which will give the global throwable json format
Notes:
By default, we will only provide two basic fields, such as the id and description fields.
Sample Project using this package
Github: https://github.com/SovathChean/spring-mongo-simple-crud.git
License
Apache-2.0 © SovathChean