Home > other >  How can I fix the issue: "Cannot resolve method 'getById' in 'EmployeeRepository
How can I fix the issue: "Cannot resolve method 'getById' in 'EmployeeRepository

Time:12-19

I've already checked similar questions, but none of them wasn't helpful for me:

  1. enter image description here

    After some investigations, I've found the cause and the way how can I fix this issue.

    CodePudding user response:

    The cause of issue was the version of the dependency as:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    

    To fix it, I needed to change the version to higher, for example, to:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    

    or to another one as:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    

    but for the usage of 2.7.5 version, you need to be careful and aware, because:

    getById(ID) is deprecated and you should use instead getReferenceById(ID).

  • Related