springBoot的數據庫操作
阿新 • • 發佈:2017-11-06
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/people7 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的數據庫操作