gpt4 book ai didi

spring - autowire = "no"和 autowire = "default"有什么区别?

转载 作者:行者123 更新时间:2023-12-01 15:13:58 25 4
gpt4 key购买 nike

autowire = "no"和 autowire = "default"有什么区别?如果它们相同,那么为什么我们有这 2 个选项。

最佳答案

Beans

The default is "default", indicating inheritance from outer 'beans' sections in case of nesting, otherwise falling back to "no" (i.e. no externally driven autowiring).

Bean

It can be shared through the 'default-autowire' attribute at the 'beans' level and potentially inherited from outer 'beans' defaults in case of nested 'beans' sections (e.g. with different profiles).

http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

在标签 <beans> 中您可以设置这组 bean 的默认 Autowiring (default-autowire)。如果您不定义它,它将使用的值将为 no。

但是如果您在 <beans> 中使用不同于“默认”或“否”的值标记,那么这个值将在你的 bean 中使用。

<beans default-autowire="ByName">
<bean autowire="default">

在上面的示例中,您的 bean 中的默认值为“ByName”。

您可以在此处查看有关 Autowiring 的更多信息:http://websystique.com/spring/spring-beans-auto-wiring-example-using-xml-configuration/

关于spring - autowire = "no"和 autowire = "default"有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39206015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com