# 애노테이션 @PostConstruct, @PreDestory

javax.annotation :  javax로 시작하면 java 진영에서 공식적으로 지원하는 것이기 때문에 스프링이 아닌 다른 컨테이너 쓰더라도 그대로 적용된다!

```java
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
```

@PostConstruct, @PreDestory 애노테이션 특징\
최신 스프링에서 가장 권장하는 방법\
애노테이션 하나만 붙이면 되므로 매우 편리\
패키지를 잘 보면 javax.annotation.PostConstruct 이다. **스프링에 종속적인 기술이 아니라 JSR-250 라는 자바 표준**이다. 따라서 스**프링이 아닌 다른 컨테이너에서도 동작**한다.\
컴포넌트 스캔과 잘 어울린다.\
**유일한 단점**은 **외부 라이브러리**에는 **적용 불가**\
**외부 라이브러리**를 **초기화, 종료** 해야 하면 **@Bean의 기능을 사용**하자. - initMethod, destroyMethod


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/spring/undefined-8/postconstruct-predestory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
