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)
Asked
Active
Viewed 1,866 times
1 Answers
0
You should be able to achieve this with the following steps, using JPA
add spring-boot-starter-data-jpa depdency
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=...
Write Entities to represent your existing tables
Create JPA-Repositories for the entities
Create service(s) to access your database
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