相关疑难解决方法(0)

spring中使用@Bean和@Component的名称和别名

我们如何定义

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

2
推荐指数
1
解决办法
4253
查看次数

标签 统计

spring ×1