SpringBoot REST API Generator
npm install generator-springboot-apiThe generator-springboot-api is a yeoman generator that builds a springboot microservices from scratch. Its goal is to assemble a pre-configured, compilable and ready-to-code spring-boot project.
To install yeoman:
```
$ npm install -g yo@latest
To install this generator:
``
$ npm install -g generator-springboot-api
Open your shell (or powershell) and type these follow commands:
* Invoke the springboot generator with yeoman
``
$ yo springboot-api
* Type a groupId using maven patterns (e.g. com.quasarbot.api)
* Type an artifactId using maven patterns (e.g. myApplication)
* Choose once embed server (mandatory)
``
undertow
tomcat
jetty
netty (webflux)
* Select the aditional options as below
``
Devtools
Mongo DB
Redis for Cache
Spring Actuator
InfluxDB for Metrics
Swagger Docs
* Select a message-queue system, if you want
``
None
RabbitMQ
Apache Kafka
MQTT
After this simple options, the generator will assembly your springboot api, using all the choosen resources.
* Compile with Maven
Once your application is assembled, compile it using maven:
``
$ cd path_to_your_app
$ mvn package -U
After this maven command, all the resources compiled can be found in the target* directory
1. JAR file compiled;
2. Scripts shell to setting up a complete docker stack (and a docker-compose file) for two environments: local machine and server;
3. Script shell to use your API with standalone docker container dependencies;
4. A complete set of curl requests, corresponding to the integrations you have chosen;
5. A postman collection to test your API.
``
$ cd target
* First, make the script executable:
``
$ chmod +x dev-stack.sh
* And finnaly execute the script:
``
$ ./dev-stack.sh
The script above will create all the docker services necessary to start up your microservice. So you can import the maven project in your favourite IDE and start to code and debug.
Note: In order to use docker stack and docker service you must initialize the swarm-mode before:
```
$ docker swarm init