How to disable spring loading of HibernateJpaAutoConfiguration

I have a spring boot project that depends on project B. project B has some .hbm.xml resources. in project A, to change the sleep 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 has this dependency HibernateJpaAutoConfiguration run

compile 'org.springframework.boot:spring-boot-starter-data-jpa'

when I run the application in gradle bootRun or maven spring-boot: run the beginning of the application and ok, but when I run java -jar I get an 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 do not know why HibernateJpaAutoConfiguration begins ??? after that I modify Application.java to like it, to exclude it, but again not work. When I copy hbm to projectA.project. Run and ok (with java -jar).

@SpringBootApplication(exclude = {HibernateJpaAutoConfiguration.class })

update

, , . hibernate-entitymanager project.spring. . HibernateJpaAutoConfiguration : D

+4
2

, , hibernate-entitymanager project.spring, . HibernateJpaAutoConfiguration : D

+3

:

import org.springframework.boot.autoconfigure.*;
import org.springframework.boot.autoconfigure.jdbc.*;
import org.springframework.context.annotation.*;

@Configuration
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class MyConfiguration {
}
+1

All Articles