1. 程式人生 > >springBoot的數據庫操作

springBoot的數據庫操作

upd ive tab 目前 com exist framework not def

1.Spring-Data-Jpa

  JPA定義了對象持久化的標準。

  目前實現了有Hibernate,TopLink

2.pom添加依賴

1         <dependency>
2             <groupId>org.springframework.boot</groupId>
3             <artifactId>spring-boot-starter-data-jpa</artifactId>
4         </dependency>
5 
6         <dependency
> 7 <groupId>mysql</groupId> 8 <artifactId>mysql-connector-java</artifactId> 9 </dependency>

3.對jps進行配置

 1 spring:
 2   profiles:
 3     active: dev
 4   datasource:
 5     driver-class-name: com.mysql.jdbc.Driver
 6     url: jdbc:mysql://127.0.0.1:3306/people
7 data-username:root 8 username: 12345678 9 jpa: 10 hibernate: 11 ddl-auto: update 12 show-sql: true

4.新建一個people的數據庫

  CREATE DATABASE IF NOT EXISTS yiibaidb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

5.

springBoot的數據庫操作