I have a services X and Y. If I want to invoke Y inside X. Is there a way to do that thru annotations. I don't want to configure a bean for X/Y, as all the other resources are Autowired for X.
Thanks!
I have a services X and Y. If I want to invoke Y inside X. Is there a way to do that thru annotations. I don't want to configure a bean for X/Y, as all the other resources are Autowired for X.
Thanks!
Spring can only inject managed instances:
@Service
public class X {
@Resource
private Y y;
}
@Service
public class Y {
}
If you do not like to add @Service to class Y, then you could use this (X will be the same)
@Configuration
public class AppConfig {
@Bean
public Y y {
return new Y();
}
}