mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-28 18:23:53 +00:00
doc[module]: boot自动装配代码整理
This commit is contained in:
@@ -35,7 +35,7 @@ public class BootAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ObjectMapper getObjectMapper() throws NoSuchFieldException {
|
||||
// 断点进入ObjectMapper,看到的确和JsonUtils用的是同一个对象
|
||||
// 拿到JsonUtils中的ObjectMapper
|
||||
Field field = JsonUtils.class.getDeclaredField("MAPPER");
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
logger.info("Jackson auto config successfully!");
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.springframework.context.annotation.Import;
|
||||
/**
|
||||
* @author godotg
|
||||
* @version 3.0
|
||||
* 笔记:通过@Import注解先注册下EventRegisterProcessor对象,当每个bean对象被注入到IOC容器后,都会经过EventRegisterProcessor这个后置处理器,
|
||||
* 从而在里面扫描每个bean对象,得到带有@EventReceiver注解的方法
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import({EventRegisterProcessor.class})
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
/**
|
||||
* @author godotg
|
||||
* @version 3.0
|
||||
* 注意:OrmConfig的装配在于具体的业务游戏中,业务游戏中不配置OrmConfig这个Bean,那么这里的Orm自动装配也不会生效。
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(OrmConfig.class)
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* 这是一个后置处理器,在boot项目中注册EventContext时,会import导入EventRegisterProcessor这个组件,这是一个后置处理器,
|
||||
* 断点发现 在AbstractAutowireCapableBeanFactory或调用getBeanPostProcessors,这样子每一个后置处理器都会走postProcessAfterInitialization这个方法
|
||||
* 断点发现 在AbstractAutowireCapableBeanFactory或调用getBeanPostProcessors,这样子每一个Bean创建后都会走postProcessAfterInitialization这个方法
|
||||
*
|
||||
* @author godotg
|
||||
* @version 3.0
|
||||
|
||||
Reference in New Issue
Block a user