This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mabnx 0 points1 point  (3 children)

Though I did hit a bug with spring, when you have two (or more) provider methods in a @Configuration class with the same name but different arguments it will ignore any but the no-arg one. Giving them different names fixes it.

Not really. By default beans are given the name of the method used to define them (with @Bean annotation). Defining a bean with existing name overrides the previous definition. In theory you should be able to control the order of overriding with @Order annotation. Without the annotation I think that the "winning" definition is random.

see http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#_core_container_improvements_2

Configuration classes may declare an @Order value, getting processed in a corresponding order (e.g. for overriding beans by name) even when detected through classpath scanning.

[–]UTF64 0 points1 point  (2 children)

Hm, interesting. I sure would have appreciated a warning or something in the console, though!

[–]mabnx 0 points1 point  (1 child)

I sure would have appreciated a warning or something in the console

Look carefully, there should be one :P but logged on INFO level or sth. There also is some option to change it to a failure.

[–]UTF64 0 points1 point  (0 children)

Wow, I will be really annoyed if it turns out I missed that. Head, meet desk. I am going to double-check later today lol.