简体   繁体   中英

Using '<import resource=' on multiple beans profiles in spring?

In my application-context.xml, I am using

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

In the dao-beans.xml file, I am using

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

I am confused as to what does this part mean -

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

Does this mean that all 3 profiles should be active for all beans inside xyz-dao-beans.xml to be imported, or even if either of the 3 is active, the xyz dao beans will be imported?

你可以参考这个文档

This is analogous to the behavior in Spring XML: if the profile attribute of the beans element is supplied eg, <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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM