1.新建项目
springboot集成h2以及可视化操作
springboot集成h2以及可视化操作
 
2.设置配置文件:
 
#h2配置
#spring.jpa.show-sql = true #启用SQL语句的日志记录
#spring.jpa.hibernate.ddl-auto = update  #设置ddl模式
#数据库的内容在最后一个连接关闭时丢失。如果要保留内容,必须像这样配置URL
#spring.datasource.url = jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
##数据库连接设置
spring.datasource.url = jdbc:h2:mem:dbtest
#spring.datasource.username = sa  #配置数据库用户名
#spring.datasource.password = sa  #配置数据库密码
#spring.datasource.driverClassName =org.h2.Driver  #配置JDBC Driver
##数据初始化设置
#进行该配置后,每次启动程序,程序都会运行resources/db/schema.sql文件,对数据库的结构进行操作。
spring.datasource.schema=classpath:db/schema.sql
#进行该配置后,每次启动程序,程序都会运行resources/db/data.sql文件,对数据库的数据操作。
spring.datasource.data=classpath:db/data.sql
##h2 web console设置
#表明使用的数据库平台是h2
spring.datasource.platform=h2
#spring.h2.console.settings.web-allow-others=true  # 进行该配置后,h2 web consloe就可以在远程访问了。否则只能在本机访问。
#进行该配置,你就可以通过YOUR_URL/h2访问h2 web consloe。YOUR_URL是你程序的访问URl。
spring.h2.console.path=/h2
#spring.h2.console.enabled=true  #进行该配置,程序开启时就会启动h2 web consloe。当然这是默认的,如果你不想在启动程序时启动h2 web consloe,那么就设置为false。
spring.h2.console.enabled=true
3.建表插入数据
springboot集成h2以及可视化操作
 
4.在浏览器中访问
springboot集成h2以及可视化操作
springboot集成h2以及可视化操作
 
 
 
 

相关文章:

  • 2022-12-23
  • 2021-08-14
  • 2021-08-24
  • 2021-12-11
  • 2021-07-02
  • 2021-05-03
  • 2021-05-22
  • 2021-08-29
猜你喜欢
  • 2021-11-21
  • 2022-01-04
  • 2021-04-04
  • 2021-07-16
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
相关资源
相似解决方案