我们以 MySQL 为例来思考这个问题:
第一步 - 把 mysql 连接器的依赖项添加至 pom.xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId></dependency>
第二步 - 从 pom.xml 中移除 H2 的依赖项
或者至少把它作为测试的范围。
<!--
<dependency>
<groupId>com.h3database</groupId>
<artifactId>h3</artifactId>
<scope>test</scope>
</dependency>
-->
第三步 - 安装你的 MySQL 数据库
更多的来看看这里 -https://github.com/in28minutes/jpa-with-hibernate#installing-and-setting-up-mysql
第四步 - 配置你的 MySQL 数据库连接
配置 application.properties
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost:3306/todo_examplespring.datasource.username=todouser
spring.datasource.password=YOUR_PASSWORD
第五步 - 重新启动,你就准备好了!欢迎大家加我qq:1038774626探讨技术问题。