Let’s consider this with MySQL as an example:

Step 1 – Add mysql connector dependencies to POM.xml
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId></dependency>Copy the code
Step 2 – Remove H2 dependencies from POM.xml

Or at least use it as a testing area.

<! -- <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>test</scope>
</dependency>
-->Copy the code
Step 3 – Install your MySQL database

More to see here – https://github.com/in28minutes/jpa-with-hibernate#installing-and-setting-up-mysql

Step 4 – Configure your MySQL database connection

Configure the application. The properties

spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost:3306/todo_examplespring.datasource.username=todouser
spring.datasource.password=YOUR_PASSWORDCopy the code
Copy the code