i have an spring boot Project A that depend to project B. project B have some .hbm.xml resources. in the project A for change hibernate configuration i add DatabaseConfiguration @Configuration for change sessionFactory
@Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource);
sessionFactoryBean.setMappingLocations("classpath*:hibernate/**/*.hbm.xml");
Properties hibernateProperties = new Properties();
hibernateProperties.put("hibernate.dialect", HIBERNATE_DIALECT);
hibernateProperties.put("hibernate.show_sql", HIBERNATE_SHOW_SQL);
sessionFactoryBean.setHibernateProperties(hibernateProperties);
return sessionFactoryBean;
}
build.gradle have this dependency HibernateJpaAutoConfiguration run
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
when i run application in gradle bootRun or maven spring-boot:run application start and ok but when i run in java -jar i get exception
caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'entityManagerFactory' defined in class path
resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:
Invocation of init method failed; nested exception is org.hibernate.MappingException:
An association from the table core_organization_Structure refers to an unmapped class: org.roshan.framework.domain.security.User
i dont know why HibernateJpaAutoConfiguration start ??? after that i change Application.java to like this for exclude that but again not work .when i copy hbm to projectA .project A run and ok (with java -jar)
@SpringBootApplication(exclude = {HibernateJpaAutoConfiguration.class })
update
after search and test ,i found problem and solve that .cause of problem was using hibernate-entitymanager dependency in project.spring boot actuator detect this and auto config entity manager .after remove this dependency disable HibernateJpaAutoConfiguration work correct :D
after search and test ,i found problem ,cause of problem was using hibernate-entitymanager dependency in project.spring boot actuator detect this and auto config entity manager .after remove this dependency disable HibernateJpaAutoConfiguration work correct :D
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments