I'm setting up a small SpringBoot application that will be using PostgreSQL as database. My idea for development was to use a H2 embedded database "passing as" the Postgre database, but I'm not really understanding what I need to do to set up everything:
1) Just in case, we are using Gradle for dependency management:
compile group: 'com.h2database', name: 'h2', version: '1.3.148'
compile group: 'org.springframework', name: 'spring-jdbc', version: '5.2.6.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.3.0.RELEASE'
2) This is my application-dev.properties ("dev" is the profile I'm running the application) (Updated after a comment down below and after reading this other question):
spring.datasource.url=jdbc:h2:mem:testdb;MODE=PostgreSQL
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.schema=classpath:/sql/schema.sql
spring.datasource.data=classpath:/sql/data.sql
spring.datasource.initialize=true
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
3) (Updated) schema.sql is our database creation script, data.sql is the data script (obviously) and both are in /resources/sql.
The issue here is that the application starts, it loads the profile (The following profiles are active: dev
), but when going to the h2 console, the database's empty. I even tried to change the name of the script (to "_ddl.sql") and the application just starts the same, as if it wasn't even trying to find the file.
Also, does it make sense to mark GenericPostgreSQL
on the H2 console options when login?
Any leads on what I'm missing here?