Skip to content

Commit

Permalink
Merge pull request #48 from hoperunChen/issues/boot3/#3001
Browse files Browse the repository at this point in the history
for TV360X-2759 springboot3使用分库数据源配置,启动提示Bean被提前实例化
  • Loading branch information
zhangdaiscott authored Oct 23, 2024
2 parents 039d769 + b489bad commit e2ce1b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion docs/修改日志.log
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ org/jeecgframework/minidao/sqlparser/impl/SimpleSqlProcessor.java(+)
org/jeecgframework/minidao/sqlparser/AbstractSqlProcessor.java(+)
org/jeecgframework/minidao/util/MiniDaoUtil.java
org/jeecgframework/minidao/util/ReflectUtil.java
---author:scott---date:2024-07-04-----for:SQL解析兼容机制(判断支持JSqlParser,才用JSqlParser引擎)---
---author:scott---date:2024-07-04-----for:SQL解析兼容机制(判断支持JSqlParser,才用JSqlParser引擎)---

---author:chenrui---date:2024/10/22-----for:[TV360X-2759]springboot3使用分库数据源配置,启动提示Bean被提前实例化 #3001---
src/main/java/org/jeecgframework/minidao/factory/MiniDaoClassPathMapperScanner.java
src/main/java/org/jeecgframework/minidao/factory/MiniDaoBeanScannerConfigurer.java
---author:chenrui---date:2024/10/22-----for:[TV360X-2759]springboot3使用分库数据源配置,启动提示Bean被提前实例化 #3001---
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jeecgframework.minidao.aop.MiniDaoHandler;
import org.jeecgframework.minidao.aspect.EmptyInterceptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
Expand Down Expand Up @@ -80,6 +81,10 @@ private void initRegisterRequestProxyHandler(BeanDefinitionRegistry registry) {
jdbcDaoProxyDefinition.getPropertyValues().add("formatSql", formatSql);
jdbcDaoProxyDefinition.getPropertyValues().add("keyType", keyType);
jdbcDaoProxyDefinition.getPropertyValues().add("showSql", showSql);
//update-begin---author:chenrui ---date:20241021 for:[TV360X-2759]springboot3使用分库数据源配置,启动提示Bean被提前实例化 #3001------------
// 标识miniDaoHandler为框架基础设施角色
jdbcDaoProxyDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
//update-end---author:chenrui ---date:20241021 for:[TV360X-2759]springboot3使用分库数据源配置,启动提示Bean被提前实例化 #3001------------
//jdbcDaoProxyDefinition.getPropertyValues().add("dbType", dbType);
if(emptyInterceptor!=null){
jdbcDaoProxyDefinition.getPropertyValues().add("emptyInterceptor", emptyInterceptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import org.apache.commons.logging.LogFactory;
import org.jeecgframework.minidao.annotation.MiniDao;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
Expand Down Expand Up @@ -42,7 +44,12 @@ public Set<BeanDefinitionHolder> doScan(String... basePackages) {
GenericBeanDefinition definition;
for (BeanDefinitionHolder holder : beanDefinitions) {
definition = (GenericBeanDefinition) holder.getBeanDefinition();
definition.getPropertyValues().add("proxy", getRegistry().getBeanDefinition("miniDaoHandler"));
//update-begin---author:chenrui ---date:20241021 for:[TV360X-2759]springboot3使用分库数据源配置,启动提示Bean被提前实例化 #3001------------
// 代理类应该引用现成的miniDaoHandler,而不是一个新的bean定义
RuntimeBeanReference miniDaoHandler = new RuntimeBeanReference("miniDaoHandler");
definition.getPropertyValues().add("proxy", miniDaoHandler);
definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
//update-end---author:chenrui ---date:20241021 for:[TV360X-2759]springboot3使用分库数据源配置,启动提示Bean被提前实例化 #3001------------
definition.getPropertyValues().add("daoInterface", definition.getBeanClassName());
if (logger.isInfoEnabled()) {
logger.info("register minidao name is { " + definition.getBeanClassName() + " }");
Expand Down

0 comments on commit e2ce1b3

Please sign in to comment.