Reputation: 3231
We have set of common spring application context configuration files. Depending on the deployment (We deploy one module or multiple module), bean injection classes will change e.g.
<bean id="tagService" class="com.ekaplus.service.tag.TagService" >
<property name="mdmTagService" ref="mdmTagService" />
<property name="physicalTagService" ref="physicalTagService" />
</bean>
physcialTagService bean will be available if physical module is deployed else it won't be available. I don't want to change the common configuration for each deployment. Is there any way in spring to ignore certain beans injection if class is not available.
Upvotes: 2
Views: 1417
Reputation: 941
You could also use a parent-child implementation by using "abstract", ie
<bean id="tagServiceParent" class="com.ekaplus.service.tag.TagService" abstract="true">
<property name="implementedTagService" ref="defaultTagService" />
..other common properties here...
</bean>
<bean id="tagService" parent="tagServiceParent">
<property name="implementedTagService" ref="mdmTagService" />
</bean>
But im not sure how you're implementing, so it might not suit your needs.
Upvotes: 1
Reputation: 299178
Well if you just use autowiring by name or by type, Spring won't autowire anything it can't find:
<bean class="foo.bar.Phleem" autowire="byType" />
Upvotes: 1