E-commerce new project study notes

Annotation @PostConstruct and @PreDestroy explanation and examples  Transfer from https://blog.csdn.net/yaerfeng/article/details/8447530

These are two annotations that affect the Servlet life cycle and are used to decorate a non-static void() method in the following ways:

@PostConstruct
Public void someMethod() {}

or

public @PostConstruct void someMethod(){}

The method modified by @PostConstruct will run when the server loads the servlet, and will only be executed once by the server. PostConstruct is executed after the constructor and before the init() method. The PreDestroy() method is executed after the destroy() method is executed

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325301244&siteId=291194637