You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "scanPackages" property requires the package name to have a trailing "." which is inconsistent with the component-scan. This feature was adding by #9415
ClassPathScanningCandidateComponentProvider (used by component-scan) constructs the scanning pattern like this:
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage) + "/" + this.resourcePattern;
AnnotationSessionFactoryBean constructs the scanning pattern like this:
String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(pkg) + RESOURCE_PATTERN;
Notice the missing "/" in the hibernate class. This means that the resource pattern is constructed like classpath*:myPackage**/.class instead of classpath:myPackage/**/*.class
This works when all persistence classes are in the package to be scanned, but fails to scan subclasses. AnnotationSessionFactoryBean should be changed to construct its pattern like component-scan does.
A workaround is to append a trailing "." onto the end of your package name.
Jeremy Haile opened SPR-5324 and commented
The "scanPackages" property requires the package name to have a trailing "." which is inconsistent with the component-scan. This feature was adding by #9415
ClassPathScanningCandidateComponentProvider (used by component-scan) constructs the scanning pattern like this:
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage) + "/" + this.resourcePattern;
AnnotationSessionFactoryBean constructs the scanning pattern like this:
String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(pkg) + RESOURCE_PATTERN;
Notice the missing "/" in the hibernate class. This means that the resource pattern is constructed like classpath*:myPackage**/.class instead of classpath:myPackage/**/*.class
This works when all persistence classes are in the package to be scanned, but fails to scan subclasses. AnnotationSessionFactoryBean should be changed to construct its pattern like component-scan does.
A workaround is to append a trailing "." onto the end of your package name.
Affects: 2.5.6
Issue Links:
Referenced from: commits 71df72d
The text was updated successfully, but these errors were encountered: