在明确定义的bean中,可以通过Spring配置类上的注释来定义init和销毁方法:@ComponentScan
public class Appconfig {为了实现与组件扫描创建的bean相同的效果,我已经阅读过,init方法应该使用@PostConstruct进行注释。但是,@PostConstru
- b is null so it'll crash here this.b = b;}
通过阅读Spring文档,我了解到基于setter的注入方法比基于构造函数的注入更值得推荐,但在上面的示例中,我需要在当前类的构造函数中使用注入的spring类,因此它必须是基于构造函数的注入,对吗?如果是这样,它看起来会是这样