【发布时间】:2015-11-03 08:52:57
【问题描述】:
我正在使用 Spring Boot 并使用注释对其进行配置。假设我有以下课程:
@FunctionalInterface
@Component
public interface VerificationStrategy {
void verify(Foo foo) throws Exception;
}
@Component
public class A {
@Autowired
public A(VerfificationStrategy assumption) {}
}
@Component
public class B {
@Autowired
public B(A a) {}
}
@Component
public class C {
@Autowired
public C(A a) {}
}
现在我想实现的目标:
B 的实例应接收具有
VerificationStrategy的一种实现的 A 实例C 的实例应该接收 A 的实例以及
VerificationStrategy的其他一些实现
使用注释实现这一目标的最优雅、最有效的方法是什么?
【问题讨论】:
标签: java spring spring-boot java-8