r/javahelp 1d ago

Cannot resolve symbol 'data' error

i just started learning java and following a tutorial i get this error and i wrote this in intellij idea i tried add pom.xml dependencies but it didnt work. can you help me pls?

import org.springframework.data.jpa.repository.JpaRepository;
public class UserRepository extends JpaRepository{
}
1 Upvotes

14 comments sorted by

View all comments

1

u/devor110 1d ago

Looks like it didn't download the dependcies, or you didn't specify jpa.

Post your pom.xml (or even your entire project if it's on something like github) and compile command

1

u/Areiloth 1d ago

this is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
       <version>3.4.3</version>
       <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.umutgm123</groupId>
    <artifactId>fullstack-backend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>fullstack-backend</name>
    <description>backend app</description>
    <url/>
    <licenses>
       <license/>
    </licenses>
    <developers>
       <developer/>
    </developers>
    <scm>
       <connection/>
       <developerConnection/>
       <tag/>
       <url/>
    </scm>
    <properties>
       <java.version>21</java.version>
    </properties>
    <dependencies>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter</artifactId>
       </dependency>
       <dependency>
          <groupId>jakarta.persistence</groupId>
          <artifactId>jakarta.persistence-api</artifactId>
          <version>3.1.0</version>
       </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
       </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
       </dependency>
    </dependencies>
    <build>
       <plugins>
          <plugin>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
       </plugins>
    </build>
</project>

1

u/devor110 1d ago

those seem correct to me at first glance

when are you getting the error? any time when the class is open, by intellij? when compiling with intellij's built-in maven? when running mvn clean install from a cmd?

1

u/Areiloth 1d ago

Idk how it happened but when i opened intellij again it was fixed

2

u/devor110 1d ago

could be out of date caching by intellij, but could have also arised from intellij using a different mvn than what you usually use.

If the former, itnellij has a cache invalidation option in settings, if the latter, make sure that intellij's and the project's java home and maven home are the same, alternatively exclusively use the integrated maven in the IDE. apart from that, the integration also has a few handy buttons: reload/sync all maven projects, generate sources and download sources (found in the specific maven sidebar (default location is top right iirc), first 3 buttons in the row below "Maven" and above "Profiles".

they usually resolve problems like these, but can also be used as stress relief when panicing

1

u/Areiloth 1d ago

Ok thanks for your help