0

I have generated a new Spring Boot project with Spring Initializr (https://start.spring.io) with the following configuration:

  • Project: Maven Project
  • Spring Boot: 2.7.2
  • Packaging: Jar
  • Java: 17
  • Dependencies: Spring Web, MySQL Driver, Validation, Spring Data JPA, Lombok

Spring initializr setup screenshot

Then I opened the project in IntelliJ (version: IntelliJ IDEA 2022.1.3 Ultimate Edition) and got this error: Cannot resolve symbol 'Entity'

Cannot resolve symbol 'Entity'

After which I checked on StackOverflow what would be the right thing to do (to double check if I should just follow IntelliJ's recommendation or do something different) and found this thread: IntelliJ IDEA highlights @Entity class names with "Cannot resolve symbol" in JPQL which recommends selecting the default JPA provider in the "Facets" configuration via File > Project Structure > Facets and then clicking on the + icon to add JPA to my project.

However this does not work and I am seeing this error: "Cannot Create Facet - No suitable modules for JPA facet found."

Image: Cannot Create Facet - No suitable modules for JPA facet found.

I have searched for this error on the internet, but basically no one ever complained about it (yet) so therefore I am quite stuck, and would really appreciate a bit of help getting on track again.

Consta Gorgan
  • 549
  • 6
  • 22
  • How does pom.xml look? Can you check if data-jpa is added to dependencies? – Vijay Kumar Jul 27 '22 at 04:31
  • As I can see you already have JPA facet added to your locker module. Make sure that default JPA provider is selected here. If the problem remains try to close the project (File | Close Project), close the IDE. Open your project is OS file explorer and delete all .iml files and the .idea directory. Then backup and delete .m2 directory and re-import the project as per https://www.jetbrains.com/help/idea/maven-support.html#maven_import_project_start – Egor Klepikov Jul 27 '22 at 07:17
  • Hi @VijayKumar, I have tried both ways (with and without `spring-boot-starter-data-jpa` commented out). Other than than I haven't made any other changes to the `pom.xml` file that Spring Initializr has auto-generated for the project. – Consta Gorgan Jul 27 '22 at 15:45
  • Hi @EgorKlepikov, the default JPA provider selected is "Hibernate". I closed the IDE, searched for `.iml` files (but there were none), deleted all `.idea` files, the `.m2` directory from `C:\Users\MyUser`, re-imported the project as per jetbrains.com, but now I ended up with an error that seems to be related to Maven (`"Use Maven wrapper is not correct maven home, reverting to embedded"`). And that's without modifying anything in the project settings / any paths / etc. – Consta Gorgan Jul 27 '22 at 16:18
  • Please contact JetBrains support at https://intellij-support.jetbrains.com/hc/en-us/requests/new and provide screenshots from `Settings/Preferences | Build, Execution, Deployment | Build Tools | Maven` and `Settings/Preferences | Build, Execution, Deployment | Build Tools | Maven | Importing` – Egor Klepikov Aug 01 '22 at 09:19

0 Answers0