title: Error creating bean with name 'entityManagerFactory' defined in class path resource.Invocation of init method failed;
body: <p>I'm using flyway to migrate the db, defined spring.jpa.hibernate.ddl-auto=validate ,start with an empty db. When I compile my Maven project, I got the following error:</p>
  
  <blockquote>
    <p>Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed;</p>
  </blockquote>
  
  <p>The detailed error is given below:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [hibernate_sequence]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1803) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  at com.exam.twister.Application.main(Application.java:11) [classes/:na]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
  at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
  at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.2.1.RELEASE.jar:2.2.1.RELEASE]
  </code></pre>
  
  <p>Im using Intellij IDEA and MySQL database</p>
  
  <p>Application.properties is</p>
  
  <pre><code>spring.jpa.hibernate.ddl-auto=validate
  spring.datasource.url=jdbc:mysql://localhost:3306/twister?allowPublicKeyRetrieval=true&amp;useSSL=false&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC
  spring.datasource.schemas=twister
  spring.datasource.username=*
  spring.datasource.password=*
  
  spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
  spring.jpa.generate-ddl=false
  spring.jpa.show-sql=true
  
  spring.flyway.baseline-on-migrate=true
  
  spring.freemarker.expose-request-attributes=true
  </code></pre>
  
  <p>V1__Init_DB.sql is</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS message(
        id bigint not null auto_increment primary key,
        filename varchar(255),
        tag varchar(255),
        text varchar(2048) not null,
        user_id bigint
  ) ENGINE=InnoDB;
  
  CREATE TABLE IF NOT EXISTS user_role(
        user_id bigint not null,
        roles varchar(255)
  ) ENGINE=InnoDB;
  
  CREATE TABLE IF NOT EXISTS usr(
        id bigint not null auto_increment  primary key,
        activation_code varchar(255),
        active tinyint(1) not null,
        email varchar(255),
        password varchar(255) not null,
        username varchar(255) not null
  ) ENGINE=InnoDB;
  
  alter table message
    add constraint message_user_fk
    foreign key(user_id) references usr (id);
  
  alter table user_role
    add constraint user_role_user_fk
    foreign key(user_id) references usr (id);
  </code></pre>
  
  <blockquote>
    <p><b>UPDATE</b></p>
    
    <p>I added this strings to my sql file and programm worked:</p>
  </blockquote>
  
  <pre><code>create table hibernate_sequence (next_val bigint) engine=InnoDB;
  insert into hibernate_sequence values ( 1 );
  insert into hibernate_sequence values ( 1 );
  </code></pre>