一 新建Spring Boot项目
1 新增依赖spring-boot-starter-data-jpa、spring-boot-starter-data-rest和ojdbc6
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.2.0</version>
</dependency>
</dependencies>
2 配置application.properties
spring.datasource.driverClassName=oracle.jdbc.OracleDriver
spring.datasource.url=jdbc\:oracle\:thin\:@localhost\:1521\:xe
spring.datasource.username=system
spring.datasource.password=oracle
#配置jpa
#Hibernate提供了根据实体类自动维护数据库表结构的功能
#create:启动时删除上一次生成的表,并根据实体类生成表,表中的数据会被清空
#create-drop:启动时候根据实体类生成表,sessionFactory关闭时表会被删除
#update:启动时会根据实体类生成表,当实体类属性表动时,表的结构也会更新,在初期开发阶段使用此选项
#validate:启动是验证实体类和数据表是否一致,在数据结构稳定时采用此选项
#none:不采取任何手段
spring.jpa.hibernate.ddl-auto=update
#用来设置Hibernate操作的时候在控制台显示真实的sql语句。
spring.jpa.show-sql=true
spring.jackson.serialization.indent_output=true
debug=true
二 实体类