I'm currently studying Spring, so I decided to write down the stumbling points as a memorandum here.
Thorough introduction to Spring Java application development with Spring Framework
Target page: p632-659 After running the app, the following error occurred on the console.
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 [meeting_room]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate
SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-
validation: missing table [meeting_room]
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException:
Schema-validation: missing table [meeting_room]
I was able to resolve the error by adding the description of the following two files.
application.properties
spring.datasource.initialization-mode=always
spring.jpa.open-in-view=true
In the previous version, if schema.sql and data.sql were placed directly under src / main / resources, it seems to be executed when the application starts. In the new version, the default of spring.datasource.initialization-mode is embedded, and it is set to be executed only by H2. Therefore, you can set anything to OK by setting it to always.
hibernate.properties
hibernate.jdbc.lob.non_contextual_creation=true
Create it in the same location as the application.properties file and write the following line.
Recommended Posts