@Autowired
private List<WalletService<Wallet>> walletServices; //Doesn't work
@Autowired
private List<WalletService> walletServices; //Everything is fine
假設我們有:春季4.2.4。自動裝配擴展通用接口列表
interface A<T extends W>;
interface B extends A<W1>;
interface C extends A<W2> ;
class W1 extends W;
class W2 extends W;
我知道這是可能注入我可以注入一個列表的或特定的A的列表,以避免一個明確的投List<A> to List<A<W>>
? 現在,當我嘗試一些我得到org.springframework.beans.factory.NoSuchBeanDefinitionException
我覺得這個功能是必要的實現類這樣的層次結構:
interface WalletService<T exends Wallet>
interface TradeWalletService extends WalletService<TradeWallet>
interface PersonalWalletService extends WalletService<PersonalWallet>
也許我失去了一些東西。 在此先感謝您的回覆!
什麼是你的春天版本? –
Spring 4.2.4版本。 – DmRomantsov