Spring ではパラメータ名による自動配線はどのように機能しますか?
温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
次の実際の例では、Bean がパラメータ名によって自動配線されています。これは機能しており、修飾子は使用されていないことに注意してください。
これはどのようにして実現できるのでお願いしますか?私のプロジェクトでは再現できません。
@Component
public class MyComponent {
public MyComponent(
// other parameters...
Counter myCounterOk,
Counter myCounterFail,
// remaining parameters...
) {
// Constructor body
}
}
public class MyConfiguration {
@Bean
public Counter myCounterOk() {
return new Counter(); // Assuming Counter instantiation is correct
}
@Bean
public Counter myCounterFail() {
return new Counter(); // Assuming Counter instantiation is correct
}
}
正文到此结束
- 本文标签: 家庭宠物
- 本文链接: https://www.coder6.net/article/2578
- 版权声明: 本文由蚂蚁原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
热门推荐
-
浏览(193) 评论(0)