When having bean factory methods with the same name but different arguments used for creating instance for different profiles the bean is not recognized for some profiles.
See example below:
Corresponding test will fail:
When using profile "B" dependencies for bean named "something" will be created successfully. Providing string value "bbb".
For profile "A" it is not working properly.
Behaviour depends on used Spring version. For releases 4.0.0. up to 4.1.4 outcome will be "bbb".
I would expect "aaa".
From release 4.1.5 on (including 5.x.x releases) a NoSuchBeanDefinitionException is thrown.
See the attached gradle project to evaluate the behaviour.