Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data JPA intelligence not working in Intellij

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

like image 687
OPK Avatar asked Nov 30 '15 16:11

OPK


People also ask

What is Spring Data JPA which problem does it solve?

JPA handles most of the complexity of JDBC-based database access and object-relational mappings. On top of that, Spring Data JPA reduces the amount of boilerplate code required by JPA. That makes the implementation of your persistence layer easier and faster.


1 Answers

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.

like image 126
Ali Dehghani Avatar answered Oct 11 '22 13:10

Ali Dehghani