springboot h2database


1. pom.xml



    com.h2database
    h2



    org.springframework.boot
    spring-boot-starter-data-jpa

2. application.properties

######################h2 database##################
spring.datasource.url=jdbc:h2:file:~/pm/DLPlatform/h2/db;MODE=MySQL;AUTO_SERVER=TRUE
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=org.h2.Driver
#spring.datasource.initialization-mode=ALWAYS
#spring.datasource.schema=classpath:db/schema.sql
#spring.datasource.data=classpath:db/data.sql
spring.h2.console.path=/h2db
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true

#################### jpa ##############################
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql= false

3.  配置中file:~/pm/DLPlatform/h2/db这个目录需要自己创建

4. 访问网页管理工具ip:port/h2db

DB