public void assertUniqueBeans ( Set < String > ignoredDuplicateBeanNames ) { for ( BeanohBeanFactoryMethodInterceptor callback : callbacks ) { Map < String , List < BeanDefinition > > beanDefinitionMap = callback . getBeanDefinitionMap ( ) ; for ( String key : beanDefinitionMap . keySet ( ) ) { if ( ! ignoredDuplicateBeanNames . contains ( key ) ) { List < BeanDefinition > definitions = beanDefinitionMap . get ( key ) ; List < String > resourceDescriptions = new ArrayList < String > ( ) ; for ( BeanDefinition definition : definitions ) { String resourceDescription = definition . getResourceDescription ( ) ; if ( resourceDescription == null ) { resourceDescriptions . add ( definition . getBeanClassName ( ) ) ; } else if ( ! resourceDescription . endsWith ( "-BeanohContext.xml]" ) ) { if ( ! resourceDescriptions . contains ( resourceDescription ) ) { resourceDescriptions . add ( resourceDescription ) ; } } } if ( resourceDescriptions . size ( ) > 1 ) { throw new DuplicateBeanDefinitionException ( "Bean '" + key + "' was defined " + resourceDescriptions . size ( ) + " times.\n" + "Either remove duplicate bean definitions or ignore them with the 'ignoredDuplicateBeanNames' method.\n" + "Configuration locations:" + messageUtil . list ( resourceDescriptions ) ) ; } } } } }
This will fail if there are duplicate beans in the Spring context . Beans that are configured in the bootstrap context will not be considered duplicate beans .