Home » Java » java – Connect a swagger generated server stub to a real mysql database-Exceptionshub

java – Connect a swagger generated server stub to a real mysql database-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am testing the creation of a REST API using swagger – generated the server stub for spring boot based on the petstore available on editor.swagger.io.

The generated model does represent my database table – it’s a simple table with some fields. I’ve created one entry to add records, one to update and another to delete.

Right now I do have an API, but as far as I know, it doesn’t connect to a real database.

Can someone provide a simple tutorial, a step by step or some sort of guide to help me out on how to use this kind of server stub (generated in swagger) to connect to a real mysql database?

How to&Answers:

After reading and testing, it seems that adding the mysql properties to the application.properties file did the trick.