-
Notifications
You must be signed in to change notification settings - Fork 2.6k
MapperScannerConfigurer cause early initialize bean #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@huangxfchn Thanks for your reporting!! Could your provide a project for reproducing bug via GitHub? |
OK, tomorrow, please. I'm off work today. |
thx!! |
@kazuki43zoo hi, I provide a project for reproducing bug via Github. when run this demo, result is as follow:
tag: factoryBean while modify
then running this demo, result is as follow:
tag: factoryBean |
Wowo, Thank you very much! |
like this: |
the above address is as followed:
|
Sorry, I made a mistake. The correct link: spring boot issue#15898 |
Prevent bean eager initialization on MapperScannerConfigurer
Thanks for your contribution!! This problem which potentially existed from previous versions, became apparent with the support of gh-376. The 2.0.5-SNAPSHOT is available via OSS NEXUS snapshot repository. Workaround until released the 2.0.5This problem can prevent by set the @Configuration
static class MyBatisConfig {
@Bean
MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer configurer = new MapperScannerConfigurer();
configurer.setBasePackage("com.example.mybatis");
configurer.setProcessPropertyPlaceHolders(false); // set to 'false'
return configurer;
}
} NoteThe mybatis-spring-boot-starter 2.1.3-SNAPSHOT is available via OSS NEXUS snapshot repository. |
there is an error happened when I used mybatis-spring-2.0.5/spring 5.2.6/mybatis3.5.5 as follow: How to solve this problem? my spring xml code <bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="locations" />
<list>
<value>classpath:mybatis/database.properties<value/>
<list>
<property/>
</bean>
<bean id="targetDataSource" class="org.springframework.jndi.jndiObjectFactoryBean">
<beans/>
---------------------------------------------------------------------------------------------------
my properties (database.properties)
targetDataSource.jndiName=aa/bb |
description
Since 2.0.2,
MapperScannerConfigurer
has changed a lot, but it brings bug.Mapperscannerconfigurer
belongs tobeandefinitionregistrypostprocessor
. During this period, the bean has not been initialized, but theprocesspropertyplaceholders()
method traverses the entireApplicationContext
, leading to the bean being instantiated in advance, becauseApplicationContext.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
The text was updated successfully, but these errors were encountered: