Spring Data Rest实战

一 新建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

二 实体类

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值