【发布时间】:2022-10-23 12:05:54
【问题描述】:
我想知道当调用来自组件的静态方法时是否调用过 @PostConstruct 方法,例如
@Component
public class SomeComponent{
@PostConstruct
void init(){ // set up static variables
};
SomeComponent{};
public static someStaticMethod{};
}
@Service
public class SomeService{
public method(){
SomeComponent.someStaticMethod(); //is @PostConstructor called here?
}
}
上面调用组件的静态方法时是否调用过 @PostConstructor 方法?如果不是,可以通过什么方式调用@PostConstructor 方法?非常感谢!
【问题讨论】:
标签: java spring spring-boot static