# @PostConstruct Annotations Using
# # @PostConstructApi Instructions for use
The > Postconstruct comment is used to perform any initialization on a method that needs to be executed after dependency injection is complete. This method must be called before the class is put into service. All classes that support dependency injection must support this comment. Even if the class does not have a request to inject any resources, the method that is annotated with postconstruct must also be called. There is only one way to comment with this comment. The method of applying the postconstruct annotation must comply with all of the following criteria: The method should not have any parameters, except in the case of the EJB Interceptor (Interceptor), in which case it will have a invocationcontext, as defined by the EJB specification. The return type of the method must be void, the method should not throw a checked exception, the method applied postconstruct can be public, protected, the package private, or private, except for the application client. The method cannot be static, the method can be final, and if the method throws an unchecked exception, the class must not be placed in the service unless it is an EJB that can handle the exception and recover from it.
In summary, it is important to note that the use of @postconstruct is:
> * Method No parameters
> * Method no return value must be void
> * Method cannot be static
> * Method cannot throw an exception
> * method executes only once
> * Using @postconstruct method can only have one in the Springbean.
# # Springbean Initialization process
"Flow
St=>start: Start
op1=>operation:spring Container Loading 1
Op2=>operation: Call constructor
Op3=>operation: @PostConstruct method call
Op4=>operation:init () call
Op5=>operation: Other code
Op6=>operation:destroy () call
Op7=>operation: @PreDestroy method call
E=>end: End
St->op1->op2->op3->op4->op5->op6->op7->e
```
@PostConstruct method is executed after the method call is constructed before the init () method.
# # Project Application Scenario
Typically used for some system configuration or for loading of cached data.
# @PreDestroy Annotations
...
[email protected] and @predestroy comments