There is a Provider<T> interface in my project, which provide some common functions.
I want to use it in Controller with generic injection of SpringFramework, in order to keep code simple and clean.
public interface Provider<T> {
...
}
@Component("myProvider")
public class MyProvider<T> implements Provider<T> {
@Autowired
private Converter<T> converter;
...
}
@RestController
public class UserController {
@Autowired
private Provider<User> provider;
...
}
@RestController
public class ProductController {
@Autowired
private Provider<Product> provider;
...
}
How to get the actual type User or Product in method of MyProvider or Converter class,
could someone please give some help?
Spring version: 5.0.9.RELEASE
Comment From: snicoll
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Comment From: cdfive
Thanks for replying! Guide me to ask in StackOverflow.
Feel free to update this issue with a link to the re-posted question (so that other people can find it)
I'm not quite understand this, does it means that if asked the question in StackOverflow, should I update this issue with the link of StackOverflow, and could discuss the question in this issue?
Comment From: snicoll
If someone else has the same question and a google search lead them to this issue, adding a link to your SO question would be an effective way to help them. The team watches SO and the community there will try to help you.
Comment From: cdfive
@snicoll Got it, thanks!