A simple example of a microservice
There are many great samples of microservices with Spring Boot 2 available on GitHub.
With the passage of time, I have thought of collecting in a mini-project all those tasks that I usually need in my day to day to accelerate my developments.
Here are some instructions on how to configure your project locally.
To get a local copy up and running follow these simple steps.
This is a list things that you need to use the software and how to configure them.
-
MongoDB Server (optional)
- We can download the Community Server from their website
- A good alternative to installing a MongoDB server is create a MongoDB container in Docker.
-
Docker Desktop
- The software can be download from their website
# Create volumes in docker to save data (optional)
docker volume create mongodb-vol
docker volume create microservices-vol
# Download and run MongoDB container
docker pull mongo
docker run -d -p 27017:27017 -v mongodb-vol:/data/db --name mongodb mongo
docker pull d4rk3on/spring-boot-2-simple-example:{version}
docker run -d -p 9080:9080 -e DEV_PATH='/' -e SPRING_PROFILES_ACTIVE='docker' -v microservices-vol:/resources --link mongodb --name spring-boot-example d4rk3on/spring-boot-2-simple-example:{version}
- Clone the repository
git clone https://github.com/D4rK3oN/spring-boot-2-simple-example.git
- Configure environment variables
Add DEV_PATH var with the path where you want to save the logs, etc
<!-- e.g. used in logback.xml -->
<file>${DEV_PATH}/resources/spring-boot-2-simple-example/logs/simple_example.log</file>
- Configure the properties of the application-dev.yml file (if you need it)
spring.data.mongodb:
host: localhost
port: 27017
- Run/Debug the project with the profile "dev"
Program args: --spring.profiles.active=dev
Swagger generated by springfox 3.0.0 : http://localhost:8080/swagger-ui/index.html#/
See the open issues for a list of proposed features (and known issues).