|
@@ -0,0 +1,16 @@
|
|
1
|
+package com.yunzhi.training.config;
|
|
2
|
+
|
|
3
|
+import org.springframework.beans.BeansException;
|
|
4
|
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
|
5
|
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
6
|
+import org.springframework.context.annotation.Configuration;
|
|
7
|
+
|
|
8
|
+@Configuration
|
|
9
|
+public class LazyInitBean implements BeanFactoryPostProcessor {
|
|
10
|
+ @Override
|
|
11
|
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
|
12
|
+ for (String beanName : beanFactory.getBeanDefinitionNames()) {
|
|
13
|
+ beanFactory.getBeanDefinition(beanName).setLazyInit(true);
|
|
14
|
+ }
|
|
15
|
+ }
|
|
16
|
+}
|