Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring data facet does not work in Intellij 14

Right now I am in progress of setup REST api template. I want to use spring boot with spring data integration, everything works nice, but I would like to take an advantages in Intellij 14 spring data plugin and enable autocompletion on i.e. findByFirstName(...) . I try to achieve something like in this intelij 11 demo http://blog.jetbrains.com/idea/2011/11/enjoy-spring-data-jpa-in-intellij-11/

How to enable spring data plugin in existing project?

My current configuration Intelij settings

@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;
        }
}
like image 290
Łukasz Tomaszewski Avatar asked Mar 28 '15 08:03

Łukasz Tomaszewski


2 Answers

It is a bug, https://youtrack.jetbrains.com/issue/IDEA-137023 should be fixed with Intelij 15

like image 64
Łukasz Tomaszewski Avatar answered Oct 04 '22 18:10

Łukasz Tomaszewski


It was a silly problem in my case - I missed enabling appropriate plugins (File -> Settings -> Plugins):

  • Database Tools and SQL
  • Hibernate Support
  • Java EE: EJB, JPA, Servlets
  • Spring Data
like image 45
lu_ko Avatar answered Oct 04 '22 20:10

lu_ko