Closed
Description
Rob Winch opened SPR-14282 and commented
Given the following classes:
public class Foo {
@Autowired
Bar bar;
}
public class Bar { }
@Configuration
public class Config {
@Bean
public Foo foo() {
return new Foo();
}
@Bean
public Bar bar() {
return new Bar();
}
}
It is not logical that the following test will fail since the autowire
attribute on @Bean
is by default NO
:
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
ctx.register(Config.class);
ctx.refresh();
Foo foo = ctx.getBean(Foo.class);
assertThat(foo.bar, nullValue());
}
Affects: 3.2.17, 4.2.6, 4.3 RC2
Issue Links:
- Should @Configuration mark @Inject fields and setters as satisfied (injected)? [SPR-14180] #18751 Should
@Configuration
mark@Inject
fields and setters as satisfied (injected)?