【发布时间】:2018-12-05 07:49:49
【问题描述】:
我正在建立一个现有的项目,我在 pom.xml 中找到了以下依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
但是hibernate没有任何依赖,所以如何检查一个项目是否使用了hibernate。
我还发现了包含以下代码的 JpaConfiguration 类。
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource);
String entities = ClassUtils.getPackageName(ArkonnApplication.class);
String converters = ClassUtils.getPackageName(Jsr310JpaConverters.class);
entityManagerFactoryBean.setPackagesToScan(new String[]{entities, converters});
entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
Properties jpaProperties = new Properties();
jpaProperties.put("hibernate.dialect", dialect);
jpaProperties.put("hibernate.hbm2ddl.auto", hbm2ddlAuto);
jpaProperties.put("hibernate.show_sql", showSql);
jpaProperties.put("hibernate.format_sql", formatSql);
jpaProperties.put("hibernate.use_sql_comments", useSqlComments);
entityManagerFactoryBean.setJpaProperties(jpaProperties);
return entityManagerFactoryBean;
}
如果这个项目正在使用休眠,那么为什么它没有任何依赖或配置。
1) Spirng boot Data JPA 是否带有默认的 Hibernate 配置?.
2) 如果是,Spring Boot Data JPA 如何在内部与 Hibernate 一起工作。(任何参考链接)
【问题讨论】:
-
mvn dependency:tree将解决您项目的所有依赖项。在那里你应该可以看到hibernate依赖
标签: spring hibernate jpa spring-data-jpa