This simple maven project presents a proof of concept of microservice for a use case of a CRUD entity with 2 different databases as implementation:
- Mongo
- Mysql
The application is profile dependent, so it can only be run by using one of the two possible database implementations.
This is the class diagram of the main clases in the project:

This project is built with maven. Using the maven wrapper provided with the project is recommended.
JDK 11 is needed.
For compiling the project and passing its test cases, you can use this:
./mvnw clean packageIf you do not have a mysql server running you can easily run it with docker with this:
docker run --name mysql \
-p 3306:3306 \
-p 33060:33060 \
-e MYSQL_ROOT_PASSWORD=root \
--restart=unless-stopped \
-d mysql:5.7 \
--character-set-server=utf8 \
--collation-server=utf8_unicode_ci \
--disable-sslThese are the standard spring.jpa/datasource properties to edit in case of need:
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/restServerWithMaven
spring.datasource.username=root
spring.datasource.password=rootBefore running the application you need to create the application database, for instance:
CREATE DATABASE restServerWithMaven;For running the server with the mysql profile enabled you can run this:
./mvnw clean spring-boot:run -Dspring-boot.run.profiles=mysqlIf you do not have a mongo server running you can easily run it with docker with this:
docker run --name mongo \
-p 27017:27017 \
--restart unless-stopped \
-d mongoThese are the standard mongodb properties to edit in case of need:
spring.data.mongodb.database=restServerWithMaven
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017For running the server with the mongo profile enabled you can run this:
./mvnw clean spring-boot:run -Dspring-boot.run.profiles=mongoOnce the server is running (with the default properties) you can navigate in your browser to the provided swagger interface:
http://localhost:8080/swagger-ui/

You can take a look at the provided postman collection for quering the app from Postman.