I configured JPA/Hibernate in Spring using Java config and without any persistence.xml
file, using the packagesToScan
property of the EntityManagerFactory
:
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource());
emf.setPackagesToScan(new String[]{"ch.gbif.swissBiodivPortal.model.entities"});
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
emf.setJpaVendorAdapter(vendorAdapter);
emf.setJpaProperties(hibernateConfigProperties());
return emf;
}
But now IntelliJ IDEA does not understand it any more, and my entities in JPAQL queries are marked in red with the following message, and auto-completion does not work :
Can't resolve symbol 'MyEntityName'
Is it possible to configure IntelliJ so it also scans a given package for JPA @Entity
?
答案 0 :(得分:2)
好吧,事实证明我没有在IntelliJ项目中正确配置Spring。
将Spring facet添加到模块并映射我的两个@Configuration
带注释的类后,IntelliJ再次完全识别我的JPAQL查询中的实体。