-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
when use @RefreshScope on @Mapper #476
Comments
Could you provide a small reproduce project? |
|
Thanks you for providing a reproduce project! I will consider to support scoped proxy bean at next version. I have a one question. |
FYI: @Mapper
@RefreshScope(proxyMode = ScopedProxyMode.NO)
public interface TestDao {
// ...
} |
I am trying to provider two functiones on my project : "dynamic database" and "config mybatis on config center ". for "config mybatis on config center ",i want move Mybatis-config.xml to config center,but mybatis does not support yml parser,so i write one.I think is ok. 这个老外看得懂中文吗? |
Could you provide a reproduce project? I'm not familiar to Spring Cloud, can't it be resolved by making the DataSource a refresh scoped bean?
Have you tried MyBatis Spring Boot? |
when use @RefrshScope on Datasource ,the bean who use Datasource must use @RefreshScope too。so mybatis should use @RefreshScope |
when the envirment changed spring will create a new context,and product some new beans,the beans in old context who was in refresh scope will be replace by new beans .if some bean not in refresh scope.it will not be replaced! if i only add RefreshScope on Datasource,the Dao will not be a new one and its datasource is also old one. |
I think it can be resolved that creating a |
I've created a demo application(prototype application) for this issue. Could you try it and please feedback if possible. Thanks! |
You can change MyBatis's beans( spring.cloud.refresh.refreshable=org.apache.ibatis.session.SqlSessionFactory,org.mybatis.spring.mapper.MapperFactoryBean For details and sample, please see a demo application(prototype application). |
See spring-projects/spring-boot#22038 about auto-configure of mybatis-spring-boot-starter is disabled when |
I support to specifies the default scope on mapper scanning features( For details, please see the following PR/Issue.
|
Already fixed on 2.2.9. |
I'm trying to get a dynamic datasource on mybatis.
while i use @RefreshScope on dao interface,an exception will occur.
the code is :
ClassPathMapperScanner ,line:196
beacuse it war RootBeanDefinition,not GenericBeanDefinition .
i can only fix it by change the source code on MapperScannerConfigurer :
The text was updated successfully, but these errors were encountered: