Java 春天4.2.4。扩展通用接口的自动布线列表 @Autowired 私人名单钱包服务//不起作用 @自动连线 私人名单钱包服务//一切都很好

Java 春天4.2.4。扩展通用接口的自动布线列表 @Autowired 私人名单钱包服务//不起作用 @自动连线 私人名单钱包服务//一切都很好,java,spring,Java,Spring,假设我们有: @Autowired private List<WalletService<Wallet>> walletServices; //Doesn't work @Autowired private List<WalletService> walletServices; //Everything is fine 接口A; 接口B扩展了A; 接口C扩展了A; W1类延伸到W类; W2类扩展了W类; 我知道可以插入a或特定a的列表。我可以插入a的列表

假设我们有:

@Autowired
private List<WalletService<Wallet>> walletServices; //Doesn't work

@Autowired
private List<WalletService> walletServices; //Everything is fine
接口A;
接口B扩展了A;
接口C扩展了A;
W1类延伸到W类;
W2类扩展了W类;
我知道可以插入a或特定a的列表。我可以插入a的列表以避免从
列表到列表的显式转换吗?
现在,当我尝试一些时,我得到org.springframework.beans.factory.NoSuchBeanDefinitionException

我认为该功能对于实现这样的类层次结构是必要的:

interface A<T extends W>;
interface B extends A<W1>;
interface C extends A<W2> ;
class W1 extends W;
class W2 extends W;
接口钱包服务
接口TradeWalletService扩展了WalletService
接口PersonalWalletService扩展了WalletService
也许我错过了什么。
提前感谢您的回复

根本原因来自Java中的泛型定义,因此
WalletService
不是
WalletService的子类,
因此Spring无法匹配bean。 其中一种解决方案可以使用上界通配符:

interface WalletService<T exends Wallet>
interface TradeWalletService extends WalletService<TradeWallet>
interface PersonalWalletService extends WalletService<PersonalWallet>

private list您的spring版本是什么?spring 4.2.4版本。@DmRomantsov您能解决这个问题吗?我面临类似的问题,无法使用任何语法自动连线
private List<WalletService<? extends Wallet>> walletServices;