Closed
Description
description
Since 2.0.2, MapperScannerConfigurer
has changed a lot, but it brings bug.
Mapperscannerconfigurer
belongs to beandefinitionregistrypostprocessor
. During this period, the bean has not been initialized, but the processpropertyplaceholders()
method traverses the entire ApplicationContext
, leading to the bean being instantiated in advance, because ApplicationContext.getBeansOfType()
will be created in advance by default.
If the bean is instantiated in advance, it will cause some problems, such as unable to rely on injection, failure to get configuration parameters, etc
code
MapperScannerConfigurer.java
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
if (this.processPropertyPlaceHolders) {
processPropertyPlaceHolders();
}
//……
}
private void processPropertyPlaceHolders() {
Map<String, PropertyResourceConfigurer> prcs = applicationContext.getBeansOfType(PropertyResourceConfigurer.class);
//……
}