【发布时间】:2016-03-02 14:22:15
【问题描述】:
@Autowired
private List<WalletService<Wallet>> walletServices; //Doesn't work
@Autowired
private List<WalletService> walletServices; //Everything is fine
假设我们有:
interface A<T extends W>;
interface B extends A<W1>;
interface C extends A<W2> ;
class W1 extends W;
class W2 extends W;
我知道可以注入 A 列表或特定 A。我可以注入 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 你能解决这个问题吗?我面临着类似的问题,无法使用任何语法自动装配