Spring bean容器< import>命令消除重复容器? [英] Does the Spring bean container <import> command eliminate duplicate containers?

查看:155
本文介绍了Spring bean容器< import>命令消除重复容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< import> 命令framework-reference / html / beans.htmlrel =nofollow noreferrer> Spring bean容器消除了重复的容器?例如,如果bean容器文件A导入B和C并且每个导入D又导入D,Spring是否会消除或忽略重复的D容器?

Does the <import> command of the Spring bean container eliminate duplicate containers? For example, if bean container file A imports B and C and each these in turn import D, does Spring eliminate or ignore the duplicate D container?

推荐答案

它不会消除重复的容器,但它会消除重复的bean定义。所以D中的bean只会在生成的bean工厂中创建一次。不过,你会得到满满的警告。

It doesn't eliminate duplicate "containers", but it will eliminate duplicate bean definitions. So the beans in D will only be created once in the resulting bean factory. You'll get a face full of warnings about it, though.

这是最好避免的。一个与另一个具有相同ID的bean定义将隐藏该bean定义,无论该bean的类型和属性是否相同。哪一个隐藏取决于声明顺序。这很危险,所以Spring会警告你。

It's something best avoided. One bean definition which has the same ID as another will "hide" that bean definition, regardless of whether or not the type and properties of that bean are the same. Which one gets "hidden" depends on the declaration order. It's dangerous, and so Spring will warn you about it.

这篇关于Spring bean容器&lt; import&gt;命令消除重复容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆