我在配置中有这个bean
@Bean
public LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean(
DataSource dataSource ) {
LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setPackagesToScan("com.x");
bean.setPersistenceUnitName("default");
bean.setDataSource(dataSource);
Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQL94Dialect");
bean.setJpaProperties(hibernateProperties);
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
bean.setJpaVendorAdapter(vendorAdapter);
return bean;
}
这适合春季靴子
@EnableJpaRepositories(basePackages = {"com.x"})
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
如何解决问题?
多谢!
您应该将以下内容提供给@EnableJpaRepositories注释
@EnableJpaRepositories(entityManagerFactoryRef = "defaultEntityManager", transactionManagerRef = "defaultTransactionManager",
basePackages = {"<complete package to dao package>"})