Spring Data JPA intelligence not working in Intellij

19,068

I solved this problem by adding JavaEE Persistence framework support. Just right click on the project, select Add Framework Support and then scroll down to find the JavaEE Persistence, then enable the checkbox and hit OK:

Enabling JavaEE Persistence Support Adding JavaEE Persistence Facet

It will add a persistence.xml file, you can delete it. Finally your auto completions will be back:

Moment of truth Moment of truth

Update You can also enable JPA facet in the Project Structure. First, press Ctrl Alt Shift S or go to Files > Project Structure. Hit the Add button and in the menu, then select JPA:

enter image description here Adding JPA Facet

And finally hit OK.

Share:
19,068
OPK
Author by

OPK

Updated on June 04, 2022

Comments

  • OPK
    OPK almost 2 years

    I have set up a spring boot project with Spring Data JPA, but I am not seeing the intelligence for Spring data jpa. enter image description here

    The screen shot shows the issue, my Restaurant entity has a variable call restaurantAddress, I am trying to let intelliJ help me finish the coding but no intelligence shows up.

    My project set up is as follows:

    Application class:

    @SpringBootApplication
    @ComponentScan(basePackages = {"com.mycompany"})
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }
    

    POM:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.mycompany</groupId>
        <artifactId>food</artifactId>
        <version>1.0-SNAPSHOT</version>
    
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.2.7.RELEASE</version>
        </parent>
    
        <dependencies>
            <!-- Dependencies for RESTful Web Services -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <!-- Dependencies for JPA Data Persistence -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-jpa</artifactId>
            </dependency>
    
            <!--JDBC-->
            <dependency>
                <groupId>postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <version>9.1-901-1.jdbc4</version>
            </dependency>
    
        </dependencies>
    
    
        <build>
            <finalName>food</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
    
            </plugins>
        </build>
    
    </project>
    

    I have Spring Data plugin installed on my IntelliJ 15, prject settings:

    enter image description here

  • gtiwari333
    gtiwari333 about 8 years
    I do not have the option "JavaEE Persistence" listed on the "Add Framework Support Dialog" . I added the dependency org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.‌​Final to POM but it is still not showing up.. Any suggestions?
  • gtiwari333
    gtiwari333 about 8 years
    I've already added JPA facet. But the intelligence is still not working.
  • Ali Dehghani
    Ali Dehghani about 8 years
    Which version of intellij? Did you check your plugins?
  • gtiwari333
    gtiwari333 about 8 years
    Intellij version is : 15.0.3
  • gtiwari333
    gtiwari333 about 8 years
  • Ali Dehghani
    Ali Dehghani almost 8 years
    @David Which version of IntelliJ?
  • Ali Dehghani
    Ali Dehghani almost 8 years
    2016.1.2 is the latest one..Is your project is a Spring Boot project?Some versions of IntelliJ does not support Spring Boot very well.
  • Sieva Kimajeŭ
    Sieva Kimajeŭ over 7 years
    If you already has JPA framework support but no completion, you should remove it and add again. It will(?) generate new configs. Worked for me.
  • Ali Dehghani
    Ali Dehghani over 7 years
    @anibyl Adding a totally useless persistence.xml sometimes will do the trick, I guess
  • akuma8
    akuma8 almost 6 years
    Intellij 2018.1.5 same issue, the @UsievaładKimajeŭ suggestion works for me. i.e remove Spring Data plugin, restart then enable it.
  • Olkunmustafa
    Olkunmustafa over 5 years
    Great answer. Thank you!
  • Marian Klühspies
    Marian Klühspies almost 5 years
    Not working for me. Removed the config multiple times. Do I have to set it to hibernate or no provider?
  • Cihangir
    Cihangir over 3 years
    Usievaład Kimajeŭ' s suggestion worked for me. Remove and add Spring Data again.
  • Seeschon
    Seeschon over 2 years
    Just add once & restart your device, it works for me