Issue
i have H2 in memory database configured with spring boot in maven multi module environment.
Spring boot log says Schema export complete,i couldn't see any table getting created in h2 database.
application.properties
#spring h2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
#Spring data JPA properties
spring.datasource.url=jdbc:h2:mem:testdb:MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.hibernate.format_sql=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
Logs:
2016-11-15 16:35:05.413 INFO 10288 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-11-15 16:35:05.429 INFO 10288 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-11-15 16:35:05.525 INFO 10288 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {4.3.11.Final}
2016-11-15 16:35:05.527 INFO 10288 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-11-15 16:35:05.529 INFO 10288 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-11-15 16:35:05.900 INFO 10288 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-11-15 16:35:05.982 INFO 10288 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2016-11-15 16:35:06.025 INFO 10288 --- [ restartedMain] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2016-11-15 16:35:06.148 INFO 10288 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2016-11-15 16:35:06.150 INFO 10288 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
Can some One explain whats wrong with the configuration.
Solution
So,it is a simple annotation which in-turn scans the entity classes.
Had it not been a multi module project,this annotation wasn't required.
Annotate the main class with @EntityScan("packageName");
Answered By - Prash
Answer Checked By - Terry (JavaFixing Volunteer)