Spring 数据方面在 Intellij 14 中不起作用
Spring data facet does not work in Intellij 14
现在我正在设置 REST api 模板。我想将 spring 引导与 spring 数据集成一起使用,一切正常,但我想利用 Intellij 14 spring 数据插件的优势并启用自动完成功能,即 findByFirstName(...)
。我尝试在这个 intelij 11 演示中实现类似的东西 http://blog.jetbrains.com/idea/2011/11/enjoy-spring-data-jpa-in-intellij-11/
如何在现有项目中启用 spring 数据插件?
我目前的配置
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories("com.test.repository")
public class TestDataBaseConfiguration {
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
entityManagerFactoryBean.setPackagesToScan("com.test.entities");
entityManagerFactoryBean.setJpaProperties(jpaProperties());
return entityManagerFactoryBean;
}
private Properties jpaProperties() {
Properties properties = new Properties();
properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
properties.setProperty("hibernate.show_sql", "false");
properties.setProperty("hibernate.format_sql", "false");
return properties;
}
@Bean
public JpaTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
transactionManager.setDataSource(dataSource());
return transactionManager;
}
}
它很大,https://youtrack.jetbrains.com/issue/IDEA-137023 应该用 Intellij 15 修复
对我来说这是一个愚蠢的问题 - 我错过了启用适当的插件 (File
-> Settings
-> Plugins
):
- 数据库工具和SQL
- 休眠支持
- Java EE:EJB、JPA、Servlet
- Spring数据
现在我正在设置 REST api 模板。我想将 spring 引导与 spring 数据集成一起使用,一切正常,但我想利用 Intellij 14 spring 数据插件的优势并启用自动完成功能,即 findByFirstName(...)
。我尝试在这个 intelij 11 演示中实现类似的东西 http://blog.jetbrains.com/idea/2011/11/enjoy-spring-data-jpa-in-intellij-11/
如何在现有项目中启用 spring 数据插件?
我目前的配置
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories("com.test.repository")
public class TestDataBaseConfiguration {
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
entityManagerFactoryBean.setPackagesToScan("com.test.entities");
entityManagerFactoryBean.setJpaProperties(jpaProperties());
return entityManagerFactoryBean;
}
private Properties jpaProperties() {
Properties properties = new Properties();
properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
properties.setProperty("hibernate.show_sql", "false");
properties.setProperty("hibernate.format_sql", "false");
return properties;
}
@Bean
public JpaTransactionManager transactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
transactionManager.setDataSource(dataSource());
return transactionManager;
}
}
它很大,https://youtrack.jetbrains.com/issue/IDEA-137023 应该用 Intellij 15 修复
对我来说这是一个愚蠢的问题 - 我错过了启用适当的插件 (File
-> Settings
-> Plugins
):
- 数据库工具和SQL
- 休眠支持
- Java EE:EJB、JPA、Servlet
- Spring数据