Reputation: 314
I am trying to setup H2 as in memory database for my test environment with spring boot. I have configured my application as:
spring.datasource.url=jdbc:h2:mem:test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.platform=postgres
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=false
spring.datasource.driverClassName=org.postgresql.Driver
But I am getting this error: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc:h2:mem:test
I am using Hikari version 3.2.0.
Upvotes: 1
Views: 4613
Reputation: 58774
Follow HikariCP or specific answer from forum which define H2 database with a different driver:
org.h2.jdbcx.JdbcDataSource
Upvotes: 0
Reputation: 3166
you used postgresql configuration. Below a configuration with hikari and H2
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:h2:mem:test
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.database=h2
spring.datasource.username=sa
spring.datasource.password=
Upvotes: 2