Esteban
Esteban

Reputation: 59

Issue upgrading from Spring Boot 1.5.4 to 2.0.0

I'm developing an application and I tried to upgrade from spring boot 1.5.4 to 2.0.0 but I have one issue with my repositories interfaces, in example:

package com.acu.repositories.it;

import com.acu.model.it.User;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends JpaRepository<User, Integer> {

List<User> findByName(String name);

User findById(Integer id);

}

It compiles ok and works fine with spring boot 1.5.4 but I'm having the following issue when I try to compile with 2.0.0 version:

com/acu/services/it/UserService.java:[52,30] error: incompatible types: Integer cannot be converted to User com/acu/repositories/it/UserRepository.java:[13,9] error: findById(Integer) in UserRepository clashes with findById(ID) in CrudRepository

ID extends Object declared in interface CrudRepository
T extends Object declared in interface CrudRepository

any idea?

Thanks.

Upvotes: 3

Views: 2939

Answers (1)

srikanth
srikanth

Reputation: 61

You can use getOne(ID) each time the new repository changes.

Upvotes: 4

Related Questions