Tuesday, April 21, 2015

IntelliJ IDEA, Spring Data Plugin, and recognizing @EnableJpaRepositories Annotation

Today I worked through an IntelliJ IDEA 14.1.1 (THE latest and greatest as of today, 4/21/2015) configuration issue that had me baffled.

I could not get IntelliJ to recognize Spring Data Repositories. 

I am using Spring JavaConfig for a Spring MVC Web Application and have the following code-based config class:


/**
 * Spring JavaConfig Web Application Configuration for Spring MVC App.
 *
 * @author Philip Tenn
 */
@Configuration
@EnableWebMvc
@EnableTransactionManagement
@ComponentScan("com.philiptenn.scholarship")
@PropertySource("classpath:application.properties")
@EnableJpaRepositories(basePackages = "com.philiptenn.scholarship.repository")
public class WebAppConfig extends WebMvcConfigurationSupport {
...
}


My issue was that the @EnableJpaRepositories annotation was not causing the IDE to recognize Spring Data JPA Repositories in my basePackage to be recognized as Spring-managed Repositories.

I have this working in other environments and could not figure out why.

I worked through the following JetBrains guide: Enabling JPA Support.  However, this did not enable IntelliJ to recognize the annotation.

Since I had this exact same project working in a different install of IntelliJ in a VM, I figured that it had nothing to do with my project and had to be something global.

Taking an educated guess, went to plugins.  Found a plugin that was disabled that looked like it could be relevant ... :-)





























After enabling the Spring Data Plugin and restarting IntelliJ ... here was my result (SO HAPPY)!



No comments:

Post a Comment