在春季在多个 bean 配置文件上使用"<import resource="?



在我的application-context.xml中,我使用

<import resource="classpath*:com/companyName/projectName/dao/dao-beans.xml"/>

在dao-bans.xml文件中,我使用

<beans profile="profile1;profile2;profile">
<import resource="classpath*:com/companyName/projectName/dao/spring/xyz/xyz-dao-beans.xml" />
</beans>

我很困惑这部分是什么意思-

<beans profile="profile1;profile2;profile">

这是否意味着xyz-dao-bans.xml中的所有bean都应该激活所有3个配置文件,或者即使其中任何一个是活动的,xyz-dao bean也将被导入?

您可以参考以下文档:

This is analogous to the behavior in Spring XML: if the profile attribute of the beans element is supplied e.g., <beans profile="p1,p2">, the beans element will not be parsed unless at least profile 'p1' or 'p2' has been activated. Likewise, if a @Component or @Configuration class is marked with @Profile({"p1", "p2"}), that class will not be registered or processed unless at least profile 'p1' or 'p2' has been activated.

相关内容

最新更新