pankaj_ar
pankaj_ar

Reputation: 765

How to avoid duplicate bean id in spring when context is loaded from different xml in SPRING

I am building an application on jboss server. For that I took a library jar and put in the same server. In that jar, in xml, 1 bean id is used which matched 1 of my bean id.

Due to that in context map, my bean-id is overridden by that jar, when I restarted jboss application.

Is there any way to detect duplicate bean id. Even if jboss will not start, the same can be tracked.

So, I need the jboss should not come up if such situation happen again.

Is there any possible way to do that??

Upvotes: 1

Views: 2117

Answers (1)

Jose Luis Martin
Jose Luis Martin

Reputation: 10709

Yes, use setAllowBeanDefinitionOverriding(false) (defined in AbstractApplicationContext) to throw a BeanDefinitionStoreException instead.

Upvotes: 2

Related Questions