我们如何定义
a) 单个名称
b) 多个名称(别名)
使用 @Bean 和 @Component 注释?
在 XML 中我们这样定义:
对于单个名称:
<bean name="accountService" autowire="constructor" class="com.wiley.beginningspring.ch2.AccountServiceImpl" autowire-candidate="false">
</bean>
Run Code Online (Sandbox Code Playgroud)
对于别名:
<bean name="accountService,a,b" autowire="constructor" class="com.wiley.beginningspring.ch2.AccountServiceImpl" autowire-candidate="false">
</bean>
Run Code Online (Sandbox Code Playgroud)
但是@Bean和@Component(或@Service,@Repository)呢?
spring ×1