skip to Main Content

I have just completed a Spring Boot tutorial of 34 videos. Im looking online and everything seems to show me how to create persistence of my data when the spring application is running. However, once I stop the program and restart it, it doesn’t have the data I want saved.

So what it sounds like is I need to store this information on a database. I think I’ve set up a MySql server on my laptop and I have the workbench app/interface.

What might be more appropriate is connecting to an online server that I have with phpmyAdmin. In any case, how do I connect my spring application to a database instead of to a localhost:8080

Please let me know where I can look and what resources I have here as I’m kind of new to this sort of thing. Much appreciated!

2

Answers


  1. There 2 options

    1. Either use persistent DB instead of in-memory storage
    2. You are using spring.jpa.hibernate.ddl-auto=create-drop hibernate property that will recreate db schema every time you start the application – thus its “clear” of the start. Use update or validate instead.
    Login or Signup to reply.
  2. Maybe you can set spring.sql.init.mode=never to not always initialize your database using scripts.
    This way you’ll find all data you saved even when re-run the app.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search