Spring通用类型依赖注入失败并启用AOP

时间:2018-01-25 16:23:01

标签: spring dependency-injection aop spring-aop

我有一个Spring Boot应用程序(1.5.9),我实现了两个转换器和一个使用其中一个的组件

readsome

一切正常并正确注入,直到使用AOP。然后我收到以下异常:

class Network {
public:
  virtual size_t readsome(char* buffer_out, size_t buffer_size) = 0;
  //is_open doesn't have to be in the interface to make the above
  //snippet compile, but it would probably belong here
};

当我将名称从@Component public class Converter1 implements Converter<A,B> { public B convert(A a) { ... } } @Component public class Converter2 implements Converter<B,C> { public C convert(B b) { ... } } @Component public class Converter1Consumer { private Converter<A,B> converter public Converter1Consumer(Converter<A,B> converter) { this.converter = converter; } ... } 更改为NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.core.convert.converter.Converter<?, ?>' available: expected single matching bean but found 2: converter1,converter2 时,一切正常。我可以理解后者为Spring匹配bean名称的参数名称。有人可以解释一下原因,AOP将参数定义转换为converter中的converter1吗?

0 个答案:

没有答案