The execution order of @ PostConstruct in ordinary Java classes

problem description

When

@ PostConstruct is executed in servlet, after the construction method and before the init method, what about in the utility class?
Today, I occasionally saw springboot injecting constants into the code of a static utility class. I found that I used PostConstruct annotations and did not understand the order of execution in this class

the environmental background of the problems and what methods you have tried

@Value("${constant.path}")
private String path;
private static String staticPath;

@PostConstruct
public void getPath() {
    staticPath = this.path;
}

Jun.05,2022

is the same, as long as this class is included in spring bean management, it is after the constructor.

Menu