Dhruv Chadha
Dhruv Chadha

Reputation: 1177

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?

Upvotes: 0

Views: 980

Answers (1)

lczapski
lczapski

Reputation: 4140

You can refer to this documentation:

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.

Upvotes: 3

Related Questions