主要内容
- 概念简介
- 配置
- 代码实现
- 常见问题
-
概念简介
JPA
Java Persistence API,Java持久层API,所谓持久层,个人浅显的理解就是和数据持久化存储相关的一层。
Hibernate
详细的解释可以看下百度百科,个人理解就是在JDBC上封装的一层,能够便利的进行数据库的操作,提供了很多的接口。参照这个博主文章。https://blog.youkuaiyun.com/xiao_xuwen/article/details/53420824
配置
application.properties配置
spring.datasource.url=jdbc:mysql://localhost:3306/databasename
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.hbm2ddl.auto=update #该属性有不同选项
spring.jpa.properties