Spring-Boot has unrecognized hibernate.hbm2ddl.auto value: NONE is not in application.properties

Viewed 333

Problem: I'm trying to run a SpringBootTest Junit but it fails due to an unrecognized property: "Unrecognized legacy hibernate.hbm2ddl.auto". I don't have that property explicitly, but I read that spring.jpa.hibernate.ddl-auto gets converted into that property.

Questions: Even if I can't get an exact answer, I hope some people can answer these questions:

  • The project uses flyway and has migration files. Does flyway replace the DDL generation done by JPA? I would think it would.
  • What property causes this exception? What value should I put there instead?
  • Does Spring-Boot use application-test.properties exclusively for tests or does that file override the main application.properties? I didn't see any Java annotation that specifies a property file.
  • How can I print out or log the actual properties file or files it actually used?

I've tried commenting out the spring.jpa.hibernate.ddl-auto, but it did not make a difference.

Snippet from application.properties

flyway.baseline-version=${BCUPLOAD_DATASOURCE_FLYWAY_BASELINE_VERSION:2.2}
server.port=${SERVER_PORT:8080}
spring.application.name=bluecost-ssc-file-generator
spring.datasource.driver-class-name=${BCUPLOAD_DATASOURCE_DRIVER}
spring.datasource.jdbcUrl=${BCUPLOAD_DATASOURCE_URL}
spring.datasource.url=${BCUPLOAD_DATASOURCE_URL}
spring.datasource.password=${BCUPLOAD_DATASOURCE_PASSWORD}
spring.datasource.username=${BCUPLOAD_DATASOURCE_USERNAME}
spring.flyway.baseline-on-migrate=${BCUPLOAD_DATASOURCE_BASELINE_ON_MIGRATE:false} 
spring.flyway.baselineOnMigrate=${BCUPLOAD_DATASOURCE_BASELINE_ON_MIGRATE:false}
spring.flyway.enabled=${BCUPLOAD_DATASOURCE_FLYWAY_ENABLED:true}
spring.flyway.locations=classpath:db/migration
spring.flyway.password=${BCUPLOAD_DATASOURCE_PASSWORD}
spring.flyway.schemas=FILE_GENERATOR
spring.flyway.url=${BCUPLOAD_DATASOURCE_URL}
spring.flyway.user=${BCUPLOAD_DATASOURCE_USERNAME}

spring.jpa.generate-ddl=false
#spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.dialect=${BCUPLOAD_DATASOURCE_DIALECT}
spring.jpa.properties.hibernate.default_schema=FILE_GENERATOR
spring.jpa.properties.hibernate.defaultSchema=FILE_GENERATOR
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
spring.jpa.show-sql=true

The "Caused by" portion of the stack trace:

Caused by: java.lang.IllegalArgumentException: Unrecognized legacy `hibernate.hbm2ddl.auto` value : `NONE`
    at org.hibernate.tool.schema.Action.interpretHbm2ddlSetting(Action.java:181)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator$ActionGrouping.interpret(SchemaManagementToolCoordinator.java:490)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:53)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1249)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:391)
    ... 4 common frames omitted

SscFileGeneratorWebApplicationShould.java Junit

package mycompany.cloud.cost.ssc.file.generator;

import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SscFileGeneratorWebApplicationShould {
    @Test
    public void contextLoads() {
        assertTrue("Should load configuration correctly", true);
    }

}

0 Answers
Related