通用mapper和mybatis-spring的关系以及与之相似的spring-data-jpa
整合东西到框架里面去就是集成框架的接口类之后进行复写:
public class MapperScannerConfigurer
extends org.mybatis.spring.mapper.MapperScannerConfigurer
从这里看出spring-mybatis本生就具备把mapper生成代理实现类,那么通用mapper就是做了单表的操作的省略,
生成是mybatis-generator
spring-data-jpa:
生成代码+成代理+单表操作省略
ClassPathBeanDefinitionScanner:
private BeanNameGenerator beanNameGenerator = new AnnotationBeanNameGenerator();///在打断点的时候不知用的到底是接口的那个实现类看前面注入的地方
protected Set
Assert.notEmpty(basePackages, "At least one base package must be specified");
Set
for (String basePackage : basePackages) {///////////////////包可以有多个
Set
for (BeanDefinition candidate : candidates) {
ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate);
candidate.setScope(scopeMetadata.getScopeName());
String beanName = this.beanNameGenerator.generateBeanName(candidate, this.registry);///在打断点的时候不知用的到底是接口的那个实现类看前面注入的地方
if (candidate instanceof AbstractBeanDefinition) {
postProcessBeanDefinition((AbstractBeanDefinition) candidate, beanName);
}
if (candidate instanceof AnnotatedBeanDefinition) {
AnnotationConfigUtils.processCommonDefinitionAnnotations((AnnotatedBeanDefinition) candidate);
}
if (checkCandidate(beanName, candidate)) {
BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(candidate, beanName);
definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
beanDefinitions.add(definitionHolder);//////////////所有的mapper都加到这个集合
registerBeanDefinition(definitionHolder, this.registry);
}
}
}
return beanDefinitions;
}