Spring H2 Support: Difference between revisions
Jump to navigation
Jump to search
Line 15: | Line 15: | ||
<span id='Dependencies'></span>To bootstrap JPA and H2, add the following dependencies: | <span id='Dependencies'></span>To bootstrap JPA and H2, add the following dependencies: | ||
<syntaxhighlight lang='groovy'> | <syntaxhighlight lang='groovy'> | ||
dependencies { | dependencies { | ||
... | |||
implementation('org.springframework.boot:spring-boot-starter-data-jpa') | implementation('org.springframework.boot:spring-boot-starter-data-jpa') | ||
runtimeOnly('com.h2database:h2') | runtimeOnly('com.h2database:h2') | ||
... | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 17:31, 31 October 2018
Internal
Playground Example
Overview
Simple Project
Use Spring Initializr to bootstrap the project. Alternatively use Spring Initializr-generated build.gradle and settings.gradle.
To bootstrap JPA and H2, add the following dependencies:
dependencies {
...
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
runtimeOnly('com.h2database:h2')
...
}
Spring Configuration
Add in application.properties or equivalent:
spring.datasource.url=jdbc:h2:tcp://localhost/mem:default
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.platform=h2
spring.datasource.initialization-mode=always
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true