Either add a field in your configuration class and annotate it with @Autowired
or add @Autowired
to the method and pass in an argument of the type.
public class MyConfig {
@Autowired
private Foo foo;
@Bean
public Bar bar() {
Bar bar = new Bar();
bar.setFoo(foo); // foo is defined in somebeans.xml
return bar;
}
}
or
public class MyConfig {
@Bean
@Autowired
public Bar bar(Foo foo) {
Bar bar = new Bar();
bar.setFoo(foo); // foo is defined in somebeans.xml
return bar;
}
}
This is all explained in the reference guide.