annotation based factory methods
You need java-config - the @Bean
annotation.
Define your class as @Configuration
and your method as @Bean
Try Java @Configuration
instead:
@Configuration
public class Config {
@Bean
public FooUser fooUser() {
return new FooUser(foo());
}
@Bean
public FooFactory fooFactory() {
return new FooFactory();
}
@Bean
public Foo foo() {
return fooFactory().createFoo();
}
}