title: How to configure Spring Boot JPA for Cucumber Integration testing?
body: <p>I have a Spring Boot project that is using PostgreSQL. I am using Spring Data and creating <code>CrudRepository</code>. This works fine for the application as I am able to use Auto Configuration and all the beans work. Now I am trying to write integration tests using Cucumber. For my tests, I want to use Spring JPA to connect to the embedded H2 database. I have created <code>DataSource</code> bean and also a repository interface that extends <code>CrudRepository</code>. When the tests boot up, it throws an exception along the lines of: </p>
  
  <pre><code>Specified class is an interface
  </code></pre>
  
  <p>I have even tried to do this manually by creating <code>LocalContainerEntityManagerFactoryBean</code> but, I am running into this exception:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getEntityManagerFactory' defined in com.package.integration.repository.RepoConfig: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  </code></pre>
  
  <p>My <code>ConfigLoaderStepDefs</code></p>
  
  <pre><code>@SpringBootTest(classes = [IntegrationTestConfig::class, JMeterRunner::class,
      RepoConfig::class])
  class ConfigLoaderStepDefs : StepDefs
  
  </code></pre>
  
  <p>My <code>RepoConfig</code></p>
  
  <pre><code>@Configuration
  @EnableJpaRepositories("&lt;repo package&gt;")
  @EnableTransactionManagement
  class RepoConfig {
  
      @Bean
      fun getEntityManagerFactory(): LocalContainerEntityManagerFactoryBean {
          return LocalContainerEntityManagerFactoryBean().also { factory -&gt;
              factory.setPackagesToScan("&lt;entities package&gt;")
              factory.jpaVendorAdapter = HibernateJpaVendorAdapter()
          }
      }
  
      @ConfigurationProperties(prefix = "spring.datasource")
      @Bean
      @Primary
      fun getDataSource(): DataSource {
  
          val dataSourceBuilder = DataSourceBuilder.create()
          dataSourceBuilder.url("jdbc:h2:mem:memorydb")
                  .username("sa")
  
          return dataSourceBuilder.build()
      }
  }
  </code></pre>
  
  <p>My <code>CucumberIT</code></p>
  
  <pre><code>@Tag("it")
  @RunWith(Cucumber::class)
  @CucumberOptions(
          plugin = ["html:build/reports/cucumber/cucumber-html-report",
              "json:build/reports/cucumber/cucumber-json-report.json"],
          features = ["classpath:features"],
          glue = ["com.package.integration"])
  @SpringBootTest
  class CucumberIT
  
  </code></pre>
  
  <p>Does anyone know who to configure JPA repository when working with cucumber?</p>