According to the Spring 5 documentation section 1.13.1
With @Profile on @Bean methods, a special scenario may apply: In the case of overloaded @Bean methods of the same Java method name (analogous to constructor overloading), an @Profile condition needs to be consistently declared on all overloaded methods.
If the conditions are inconsistent, only the condition on the first declaration among the overloaded methods will matter.
If methods are overloaded, that means the methods return beans of the same type. The container does not know which bean to inject or autowire in this situation even if the active profile is set.
I think using @Primary on one of the bean methods can tell the container which bean to inject. The order of methods' declaration does not matter as the document describes.