spring boot笔记

spring boot配置初始sql:spring boot关于初始sql脚本的配置有以下几个:

  1. spring.datasource.initialize=true # populate using data.sql  

  2. spring.datasource.schema= # a schema (DDL) script resource reference  

  3. spring.datasource.data= # a data (DML) script resource reference  

  4. spring.datasource.platform= # the platform to use in the schema resource (schema-${platform}.sql)  

这里说下DDl和DML等:

DDL:数据库模式定义语言,关键字:create
DML:数据操纵语言,关键字:Insert、delete、update
DCL:数据库控制语言 ,关键字:grant、remove
DQL:数据库查询语言,关键字:select

再对应上面的注释,很容易就知道如何配置初始化sql脚本了


spring.datasource.data=classpath:data.sql


在data.sql中指定要导入的初始化数据


关于spring-data-jpa的entity DDL自动create-drop,如果使用的是h2database这样的内存数据库,那么这个属性是自动设为true的:

spring.jpa.hibernate.ddl-auto= # defaults to create-drop for embedded dbs 


如果你使用的不是内存数据库,那么必须手动配置这个项为true

# Hibernate ddl auto (create, create-drop, update): with "update" the database

# schema will be automatically updated accordingly to java entities found in

# the project

spring.jpa.hibernate.ddl-auto = update

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值