I have encountered a strange problem. I am under the impression that component scan scans the sub packages recursively if a top level package is specified for scanning.
My repositories and entities are the maven dependency of the project. They live under the package name com.foo.bar.xyz and my application config is under package com.foo.bar. When I write @ComponentScan(basePackages = "com.foo.bar")
, along with @EnableJpaRepositories
it gives an error that repository bean not found.
However when I specify a top level repository package like @EnableJpaRepositories(basePackages = com.foo.bar.xyz)
, along with component scan as above, it detects the repository just fine.
Now is this happening only because the repositories and entities are being injected as maven dependency? So does the recursive part of component scan, scans the sub packages or the subdirectories?
@EnableJpaRepositories
annotation – Toothlike