|
@@ -57,6 +57,7 @@ import java.util.List;
|
|
* configuration file is specified as a property, those will be considered,
|
|
* configuration file is specified as a property, those will be considered,
|
|
* otherwise this auto-configuration will attempt to register mappers based on
|
|
* otherwise this auto-configuration will attempt to register mappers based on
|
|
* the interface definitions in or under the root auto-configuration package.
|
|
* the interface definitions in or under the root auto-configuration package.
|
|
|
|
+ * </p>
|
|
*
|
|
*
|
|
* @author Eddú Meléndez
|
|
* @author Eddú Meléndez
|
|
* @author Josh Long
|
|
* @author Josh Long
|
|
@@ -81,9 +82,9 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
|
|
private final DatabaseIdProvider databaseIdProvider;
|
|
private final DatabaseIdProvider databaseIdProvider;
|
|
|
|
|
|
private final List<ConfigurationCustomizer> configurationCustomizers;
|
|
private final List<ConfigurationCustomizer> configurationCustomizers;
|
|
-
|
|
|
|
|
|
+
|
|
private final ApplicationContext applicationContext;
|
|
private final ApplicationContext applicationContext;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
public MybatisPlusAutoConfiguration(MybatisPlusProperties properties,
|
|
public MybatisPlusAutoConfiguration(MybatisPlusProperties properties,
|
|
ObjectProvider<Interceptor[]> interceptorsProvider,
|
|
ObjectProvider<Interceptor[]> interceptorsProvider,
|
|
@@ -98,12 +99,12 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
|
|
this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable();
|
|
this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable();
|
|
this.applicationContext = applicationContext;
|
|
this.applicationContext = applicationContext;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void afterPropertiesSet() {
|
|
public void afterPropertiesSet() {
|
|
checkConfigFileExists();
|
|
checkConfigFileExists();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private void checkConfigFileExists() {
|
|
private void checkConfigFileExists() {
|
|
if (this.properties.isCheckConfigLocation() && StringUtils.hasText(this.properties.getConfigLocation())) {
|
|
if (this.properties.isCheckConfigLocation() && StringUtils.hasText(this.properties.getConfigLocation())) {
|
|
Resource resource = this.resourceLoader.getResource(this.properties.getConfigLocation());
|
|
Resource resource = this.resourceLoader.getResource(this.properties.getConfigLocation());
|
|
@@ -211,19 +212,19 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
|
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
|
-
|
|
|
|
|
|
+
|
|
if (!AutoConfigurationPackages.has(this.beanFactory)) {
|
|
if (!AutoConfigurationPackages.has(this.beanFactory)) {
|
|
logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled.");
|
|
logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled.");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
logger.debug("Searching for mappers annotated with @Mapper");
|
|
logger.debug("Searching for mappers annotated with @Mapper");
|
|
-
|
|
|
|
|
|
+
|
|
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
|
|
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
|
|
if (logger.isDebugEnabled()) {
|
|
if (logger.isDebugEnabled()) {
|
|
packages.forEach(pkg -> logger.debug("Using auto-configuration base package '{}'", pkg));
|
|
packages.forEach(pkg -> logger.debug("Using auto-configuration base package '{}'", pkg));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
|
|
ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
|
|
if (this.resourceLoader != null) {
|
|
if (this.resourceLoader != null) {
|
|
scanner.setResourceLoader(this.resourceLoader);
|
|
scanner.setResourceLoader(this.resourceLoader);
|
|
@@ -256,7 +257,7 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
|
|
@Import({AutoConfiguredMapperScannerRegistrar.class})
|
|
@Import({AutoConfiguredMapperScannerRegistrar.class})
|
|
@ConditionalOnMissingBean(MapperFactoryBean.class)
|
|
@ConditionalOnMissingBean(MapperFactoryBean.class)
|
|
public static class MapperScannerRegistrarNotFoundConfiguration implements InitializingBean {
|
|
public static class MapperScannerRegistrarNotFoundConfiguration implements InitializingBean {
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void afterPropertiesSet() {
|
|
public void afterPropertiesSet() {
|
|
logger.debug("No {} found.", MapperFactoryBean.class.getName());
|
|
logger.debug("No {} found.", MapperFactoryBean.class.getName());
|