泛型依赖注入

泛型依赖注入

1.定义泛型

Java代码:

package com.spring.generic;

import org.springframework.beans.factory.annotation.Autowired;

public class BaseService {
    
    @Autowired
    protected BaseRepository repository;

    public void add() {

        System.out.println("BaseService Add user");
        System.out.println(repository);
    }

}

2.实现基类,声明泛型

Java代码:

package com.spring.generic;

import org.springframework.stereotype.Service;

@Service
public class GUserService extends BaseService {

}

xml代码:



    

    

你可能感兴趣的:(泛型依赖注入)