Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在创建基本控制器时使用泛型有困难_Java_Spring_Spring Boot - Fatal编程技术网

Java 在创建基本控制器时使用泛型有困难

Java 在创建基本控制器时使用泛型有困难,java,spring,spring-boot,Java,Spring,Spring Boot,我想创建一个基本控制器,使用如下的泛型 @RestController public class BaseController<T extends BaseEntity, S extends BaseServiceI<T, D extends BaseDao<T>>> { @Autowired private HttpServletRequest mRequest; @Autowired private HttpServletR

我想创建一个基本控制器,使用如下的泛型

@RestController
public class BaseController<T extends BaseEntity, S extends BaseServiceI<T, D extends BaseDao<T>>> {
    @Autowired
    private HttpServletRequest mRequest;
    @Autowired
    private HttpServletResponse mResponse;

    @Autowired
    private S service;


您的类型参数不正确,请更改它们

发件人:


致:



太棒了!这对我很有用!我有一个新问题,你能帮我看一下吗?如果你有两个接口实现,并且你正试图注入其中一个,你需要将其中一个标记为
@Primary
或使用
@限定符
public interface BaseServiceI<T, V extends BaseDao<T>> {

public class ProjectInfoController extends BaseController<ProjectInfo, ProjectInfoServiceI, ProjectInfoDao> {


Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

[2020-12-15 22:35:09:719] Failed to read the entry class, please make sure the accuracy of the registration certificate!Error creating bean with name 'baseController': Unsatisfied dependency expressed through field 'service'; nested exception is 
<T extends BaseEntity, S extends BaseServiceI<T, D extends BaseDao<T>>>
<T extends BaseEntity, S extends BaseServiceI<T, D>, D extends BaseDao<T>>