springboot h2database

1. pom.xml

<!-- h2 database -->
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
</dependency>
<!-- jpa -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

 

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

 

posted @ 2022-05-23 10:42  jason47  阅读(118)  评论(0编辑  收藏  举报