项目实战Tally项目开发调试总结情况一:混淆Bean

在 init() 方法执行成功,字段已正常初始化。 但 appendAction 中 targetFile 仍为 null,log发现在进入方法就为null 在 TagServiceImpl 的无参构造器中,使用了 new ActionLogService() 手动创建了一个新的实例,而不是通过 Spring 依赖注入。这导致 TagServiceImpl 持有的 actionLogService 不是 Spring 容器中已经初始化好的那个 bean,而是一个全新的、未经过 @PostConstruct 初始化的实例,因此其内部的 actionsDir 和 metaLogPath 字段为 null。 这就是为什么在 appendAction 中看到 metaLogPath=null, actionsDir=null 的原因。

Built with LogoFlowershow