xxxxxxxxxx
// use it only for testing (recommended)
// make sure to put schema and data .sql script inside src/main/resources
// pom.xml (add dependencies)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
// application.properties
logging.level.org.springframework[.jdbc.datasource.init.ScriptUtils]=debug // allows to see output when data is loaded as log
spring.h2.console.enabled=true // allows us to access the h2 database console through "localhost:8080/h2-console"
spring.datasource.url=jdbc:h2:mem:testdb // use in-memory database (put jdbc:h2:mem:testdb in URL console)
// NOTE: Any .sql file inside src/main/resources will now be automatically picked up by h2
xxxxxxxxxx
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto= update
spring.h2.console.enabled=true
# default path: h2-console
spring.h2.console.path=/h2-ui
xxxxxxxxxx
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect