[Spring] @PostConstruct 사용 후 다른 클래스에서 호출 방법
Spring 실행 될 때 초기에 한 번 호출하여 메모리에 저장 후 사용하고 싶을 때 @PostConstruct 을 사용해주면 됩니다. @Component public class PostConTest { @Autowired Mapper mapper; public static String str; public static ResDao resDao; @PostConstruct public void init(){ str = "testtest"; resDao = mapper.selectTest(); } } @Component 어노테이션을 가진 독립적인 클래스를 생성해줍니다. 디버깅을 해보시면 Spring was가 다 실행되기 전에 우선 init() 함수가 실행 됩니다. 이때 @PostContuct가 없었다면 @A..