I have below class where I am trying to inject some JpaRepository
dependency.
class Sample<T> implements SampleInterface<T> {
@Autowired
JpaRepository<T, Long> jpaRepository; // Want this to be injected by spring using A as entity
}
class Main {
@Bean
Sample<A> sample() {
return new Sample<A>(); // A is a jpa entity
}
}
Is it because annotations are parsed during compilation? Why can't spring make the autowiring dynamic using generics? I may be missing the fundamentals, but curious to fill that knowledge gap.