Reputation: 1069
spring-boot-starter-parent 2.3.2.RELEASE
I'm trying to access the dababase like in this tutorial:
https://spring.io/guides/gs/accessing-data-jpa/#_create_simple_queries
This is my repository:
package ru.pcask.clients.repositories;
import ru.pcask.clients.entities.Client;
import org.springframework.data.repository.CrudRepository;
public interface ClientRepository extends CrudRepository<Client, Long> {
Client findById(Long id);
}
And the error:
'findById(Long)' in 'ru.pcask.clients.repositories.ClientRepository' clashes with 'findById(ID)' in 'org.springframework.data.repository.CrudRepository'; attempting to use incompatible return type
But I get errors like in the screenshot.
Upvotes: 0
Views: 837
Reputation: 602
The issue is your return type. As mentioned above, the method findById(Long id)
is already implemented in the CrudReposistory<T, ID>
and it returns an Optional<T>
.
You can either remove the method in your code because it is already there or override it with the correct return type Optional<Client>
.
Upvotes: 2