|
@@ -1,23 +0,0 @@
|
|
|
-package com.zkqy;
|
|
|
-
|
|
|
-import com.zkqy.web.controller.tool.DynamicBeanRegistrar;
|
|
|
-import org.springframework.boot.context.event.ApplicationReadyEvent;
|
|
|
-import org.springframework.context.ApplicationListener;
|
|
|
-import org.springframework.context.ConfigurableApplicationContext;
|
|
|
-
|
|
|
-public class DynamicBeanRegistrarInitializer implements ApplicationListener<ApplicationReadyEvent> {
|
|
|
- @Override
|
|
|
- public void onApplicationEvent(ApplicationReadyEvent event) {
|
|
|
- // 获取 ConfigurableApplicationContext
|
|
|
- ConfigurableApplicationContext applicationContext = event.getApplicationContext();
|
|
|
-
|
|
|
- // 创建 DynamicBeanRegistrar 实例
|
|
|
- DynamicBeanRegistrar dynamicBeanRegistrar = new DynamicBeanRegistrar(applicationContext);
|
|
|
-
|
|
|
- // 注册到 Spring 容器
|
|
|
- applicationContext.getBeanFactory().registerSingleton("dynamicBeanRegistrar", dynamicBeanRegistrar);
|
|
|
-
|
|
|
- // 打印确认
|
|
|
- System.out.println("DynamicBeanRegistrar registered successfully!");
|
|
|
- }
|
|
|
-}
|