2

i have an existing database and existing table my MySQL database that holds data. I want to perform a get to display all data the from the existing table to the user. however, every tutorial i find involves creating a new database and a new table of example data, but i want to import an already existing database and table into a new Spring Boot application to perform endpoint functions on it. how do i go about this? thanks. (assume it's production data in the database)

CokeVoAYCE
  • 33
  • 6

1 Answers1

0

You should be able to achieve this with the following steps, using JPA

  1. add spring-boot-starter-data-jpa depdency

  2. configure database-connection in your application.properties

    spring.jpa.hibernate.ddl-auto=none

    spring.datasource.url=...

    spring.datasource.username=...

    spring.datasource.password=...

    spring.datasource.driver-class-name=...

  3. Write Entities to represent your existing tables

  4. Create JPA-Repositories for the entities

  5. Create service(s) to access your database

  6. Create a controller and inject the service(s)

The spring.jpa.hibernate.ddl-auto property is important to ensure that you do not delete or modify existing entries on startup/cleanup. More details here.

Turtle
  • 86
  • 8