本文共 569 字,大约阅读时间需要 1 分钟。
每次编一些简单的应用总是要创建表,安装数据库非常繁琐
这里可以通过 H2 数据库的持久化功能来达到和Mysql一样功能,且不需要安装数据库非常便利
spring: datasource: driver-class-name: org.h2.Driver url: jdbc:h2:file:/www/${ spring.application.name}/db # Windows # url: jdbc:h2:file:C:/data/sample/${spring.application.name}/db; username: sa password: jpa: hibernate: ddl-auto: update database-platform: org.hibernate.dialect.H2Dialect h2: console: path: /h2 enabled: true settings: web-allow-others: true
把url 修改文件类型,然后设置spring.jpa.hibernate.ddl-auto=update
h2 的访问配置根据喜好来吧
[1].
转载地址:http://tcqof.baihongyu.com/