spring - How to specify packagesToScan in HibernateJpaAutoConfiguration? -


i'm using hibernatejpaautoconfiguration directly in spring unit test. while hibernate , entitymanager configured, no entities scanned.

exception

10:29:36.377 [main] info  o.s.b.f.a.autowiredannotationbeanpostprocessor - jsr-330 javax.inject.inject' annotation found , supported autowiring 10:29:36.505 [main] trace o.s.b.b.propertiesconfigurationfactory - property sources: org.springframework.boot.context.properties.configurationpropertiesbindingpostprocessor$flatpropertysources@65f8f5ae 10:29:36.638 [main] trace o.s.b.b.propertiesconfigurationfactory - property sources: org.springframework.boot.context.properties.configurationpropertiesbindingpostprocessor$flatpropertysources@65f8f5ae 10:29:36.716 [main] trace o.s.b.b.propertiesconfigurationfactory - property sources: org.springframework.boot.context.properties.configurationpropertiesbindingpostprocessor$flatpropertysources@65f8f5ae 10:29:36.818 [main] info  o.s.o.j.localcontainerentitymanagerfactorybean - building jpa container entitymanagerfactory persistence unit 'default' 10:29:36.842 [main] info  o.h.jpa.internal.util.loghelper - hhh000204: processing persistenceunitinfo [     name: default     ...] 10:29:36.979 [main] info  org.hibernate.version - hhh000412: hibernate core {4.3.6.final} 10:29:36.980 [main] info  org.hibernate.cfg.environment - hhh000206: hibernate.properties not found 10:29:36.982 [main] info  org.hibernate.cfg.environment - hhh000021: bytecode provider name : javassist 10:29:37.234 [main] info  o.h.annotations.common.version - hcann000001: hibernate commons annotations {4.0.4.final} 10:29:37.599 [main] info  org.hibernate.dialect.dialect - hhh000400: using dialect: org.hibernate.dialect.postgresql9dialect 10:29:37.608 [main] info  o.h.e.j.internal.lobcreatorbuilder - hhh000424: disabling contextual lob creation createclob() method threw error : java.lang.reflect.invocationtargetexception 10:29:37.648 [main] info  o.h.h.i.a.astquerytranslatorfactory - hhh000397: using astquerytranslatorfactory 10:29:37.742 [main] info  o.h.tool.hbm2ddl.schemaupdate - hhh000228: running hbm2ddl schema update 10:29:37.742 [main] info  o.h.tool.hbm2ddl.schemaupdate - hhh000102: fetching database metadata 10:29:37.744 [main] info  o.h.tool.hbm2ddl.schemaupdate - hhh000396: updating schema 10:29:37.745 [main] info  o.h.tool.hbm2ddl.schemaupdate - hhh000232: schema update complete 

my workaround create own localcontainerentitymanagerfactorybean follows:

    final localcontainerentitymanagerfactorybean factorybean = new localcontainerentitymanagerfactorybean();     factorybean.setpersistenceunitname("buzzpu"); // persistence.xml     factorybean.setdatasource(datasource);     factorybean.setjpavendoradapter(jpavendoradapter);     factorybean.setpersistencexmllocation("classpath*:meta-inf/donotparsepersistence.xml");     factorybean.setpackagestoscan("org.soluvas.buzz.core.jpa"); 

note don't use meta-inf/persistence.xml

from spring boot reference...

62.4 separate @entity definitions spring configuration

spring boot tries guess location of @entity definitions, based on @enableautoconfiguration finds. more control, can use @entityscan annotation, e.g.

@configuration @enableautoconfiguration @entityscan(basepackageclasses=city.class) public class application {    //... } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -