[英]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:我正在开发一个应用程序,我试图从 spring boot 1.5.4 升级到 2.0.0,但我的存储库接口有一个问题,例如:
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:它编译正常并且在 spring boot 1.5.4 上工作正常但是当我尝试使用 2.0.0 版本编译时遇到以下问题:
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 com/acu/services/it/UserService.java:[52,30] 错误:类型不兼容:无法将整数转换为用户 com/acu/repositories/it/UserRepository.java:[13,9] 错误:findById(Integer ) 在 UserRepository 中与在 CrudRepository 中的 findById(ID) 冲突
ID extends Object declared in interface CrudRepository
T extends Object declared in interface CrudRepository
any idea?任何的想法?
Thanks.谢谢。
You can use getOne(ID)
each time the new repository changes.每次新存储库更改时,您都可以使用getOne(ID)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.