leelee.log
[Spring] Bean LifeCycle 본문
모든 포스팅에서 Bean 얘기를 하고 있는 느낌인데 오늘은 좀 심화된 Bean의 얘기를 할 것이다. Spring은 그냥 자바 객체를 쓰지 왜 Bean이라고 하는 별도의 개념을 또 만들어냈을까? 왜냐하면 의존성 주입(DI)가 하고 싶고, 스코프(객체의 활동 범위 정도라고 이해 했다)를 관리하고 싶었기 때문이다. Request를 물어오는 AController 객체가 하나면 충분하지 꼭 두 개, 세 개 여러 개 일 필요가 있을까? 그럴 필요 없다. 또 db와 연결을 하는 repository 객체는 하나 만드는데 꽤 비용이 든다. Spring은 이렇게 꼭 하나만 만들어도 되는 객체면 하나만 만들어서 쓰고 싶어 한다. 별 거 안 해도 무거운 자바에게는 필수적인 선택이었을 것이다. 그래서 단일 스코프로 작동하기 위해 Singleton 패턴을 도입했다. 참고로 Singleton이 아닌 일반 자바같이 객체를 만드는 방법은 Prototype이라고 한다.
이렇게 만들어져서 Spring이 관리를 해주는 Bean에도 객체 주기가 있다. 나는 주로 Spring 프로젝트를 jar 파일로 만들어서 배포하니 여기서도 jar을 사용해서 설명을 하도록 하겠다. Bean으로 등록된 객체는 jar 파일을 실행 시켰을 때 (서버가 살아날 때) 만들어져 IoC에 담기고, 내가 일부러 빈을 따로 없애는 코드를 사용하지 않았다면 jar 파일 실행을 취소했을 때 (서버를 내릴 때) 없어진다. 밑에 Bean 겍체주기를 보여주는 그림을 한 번 보자.
1. annotation
@PostConstruct
-막 bean 객체가 초기화가 되었을 때 호출이 된다. Cilent에게 호출되기 전에 서버에서 미리 준비를 해야 할 부분이 있다면 @PostConstruct를 사용하여 객체가 초기화 되자마자 일을 시킬 수 있다. 나는 DB와 관련된 Bean에서 자주 사용하는데 미리 DB에서 데이터를 가져와서 서버에 캐싱을 해둬서 Client가 정보를 요청하면 빠르게 줄 수 있는 형식으로 사용했다. 자주 바뀌는 대용량의 데이터에서 보다는 자주 바뀌지 않는 메타데이터를 캐싱하는데 쓰기 좋았다.
@PreDestroy
-Bean이 IoC에서 제거되기 직전에 호출된다. 한 번 도 Bean을 의도적으로 죽여본적이 없어서 어디에 사용할지 감이 잘 안 왔었는데 DB 커넥션등 유지비용이 많이 드는 작업 같은 경우 서버를 내리지는 않고 Bean만 죽여야 하는 상황이라면 Release 해주는게 서버의 성능 향상에 좋을 것 이다.
2. BeanPostProcessor
postProcessBeforeInitialization, postProcessAfterInitialization
-postProcessBeforeInitialization의 경우에는 Bean이 정말 '만들어지기만' 했을 때 호출이 된다고 한다. 제일 처음으로 Bean에 관련된 작업을 할 수 있는 메소드인듯 하다. 두 메소드를 사용해서 예제를 한 번 만들어 봤는데 @PostConstruct나 @PreDestroy처럼 딱 한 번 씩만 호출이 될 줄 알았으나 stck trace를 보니 굉장히 자주 호출이 되었다. 아무래도 해당 Bean에 관련된 다른 모든 Bean들에 대해서도 호출이 되는게 아닌가 싶다.
stack trace 확인하기 (▽)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.4.RELEASE)
2020-03-13 11:05:18.396 INFO 16892 --- [ restartedMain] com.example.tstory.TStoryApplication : Starting TStoryApplication on DESKTOP-HR4H108 with PID 16892 (C:\ideaprojects\self\t-story\out\production\classes started by absin in C:\ideaprojects\self\t-story)
2020-03-13 11:05:18.410 INFO 16892 --- [ restartedMain] com.example.tstory.TStoryApplication : No active profile set, falling back to default profiles: default
2020-03-13 11:05:18.505 INFO 16892 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-03-13 11:05:18.505 INFO 16892 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-03-13 11:05:19.720 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : TestService Bean은 지금 막 태어났습니다
2020-03-13 11:05:19.729 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:19.729 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:19.785 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:19.785 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:19.921 INFO 16892 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-03-13 11:05:19.937 INFO 16892 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-13 11:05:19.937 INFO 16892 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-03-13 11:05:20.066 INFO 16892 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-13 11:05:20.066 INFO 16892 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1561 ms
2020-03-13 11:05:20.071 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.071 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.073 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.074 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.093 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.093 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.100 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.100 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.113 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.114 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.124 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.124 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.127 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.127 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.141 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.141 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.147 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.147 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.165 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.167 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.169 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.170 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.175 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.176 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.177 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.178 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.181 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.182 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.227 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.230 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.232 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.233 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.245 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.245 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.249 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.250 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.251 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.251 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.252 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.252 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.253 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.253 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.253 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.253 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.255 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.255 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.276 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.276 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.276 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.276 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.277 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.277 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.278 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.278 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.278 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.278 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.279 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.279 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.281 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.281 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.285 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.285 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.285 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.285 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.291 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.301 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.301 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.301 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.302 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.302 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.304 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.304 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.318 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.318 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.318 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.318 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.324 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.324 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.325 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.325 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.325 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.325 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.332 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.332 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.333 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.333 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.365 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.366 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.367 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.367 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.379 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.379 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.388 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.388 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.393 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.393 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.413 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.414 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.420 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.421 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.431 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.431 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.433 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.434 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.436 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.436 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.438 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.438 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.440 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.440 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.446 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.447 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.447 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.448 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.453 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.453 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.457 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.457 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.457 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.457 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.459 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.460 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.462 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.462 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.488 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.488 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.490 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.490 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.496 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.496 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.510 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.511 INFO 16892 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-03-13 11:05:20.511 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.522 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.598 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.604 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.604 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.630 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.697 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.709 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.710 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.714 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.714 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.716 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.717 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.721 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.722 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.727 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.728 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.730 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.734 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.754 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.755 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.755 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.755 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.757 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.757 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.759 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.759 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.760 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.760 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.760 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.760 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.771 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.771 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.773 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.773 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.782 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.783 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.786 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.786 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.792 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.792 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.793 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.793 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.815 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.815 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.830 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.830 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.835 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.835 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.837 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.837 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.845 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.845 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.852 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.852 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.853 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.853 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.855 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.856 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.859 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.860 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.885 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.885 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.892 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.893 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.893 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.894 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.897 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.898 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.907 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.908 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.908 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.908 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.908 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.908 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.909 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.909 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.920 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.921 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.921 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.921 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.922 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.922 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.924 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.924 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.926 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.927 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.930 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.930 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.933 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.933 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.937 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.937 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.937 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.937 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.937 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.939 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.945 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.945 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.946 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.946 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.947 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.947 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.948 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.948 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.948 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.948 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.951 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.951 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.956 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.956 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.957 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.957 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.960 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.961 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.962 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.962 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.965 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.965 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.967 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.975 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.976 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.976 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.976 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.977 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.981 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.981 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.982 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.984 INFO 16892 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-03-13 11:05:20.985 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.986 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.986 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:20.987 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessBeforeInitialization) called
2020-03-13 11:05:20.987 INFO 16892 --- [ restartedMain] com.example.tstory.service.TestService : (TestService.postProcessAfterInitialization) called
2020-03-13 11:05:21.077 INFO 16892 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-03-13 11:05:21.088 INFO 16892 --- [ restartedMain] com.example.tstory.TStoryApplication : Started TStoryApplication in 3.592 seconds (JVM running for 6.244)
Disconnected from the target VM, address: '127.0.0.1:53825', transport: 'socket'
2020-03-13 11:05:27.319 INFO 16892 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-03-13 11:05:27.321 INFO 16892 --- [extShutdownHook] com.example.tstory.service.TestService : TestService Bean은 이제 죽은 목숨 입니다.
Process finished with exit code 130
3. InitializingBean, DisposableBean
-@PostConstruct, @PreDestroy와 비슷한 동작을 한다. interface들이라서 상속을 해주고 afterPropertiesSet와 destroy 메소드를 오버라이드 하면 된다. 다중 상속을 하면 둘 다 사용을 할 수 있다. 그런데 이 interface들은 Spring에서만 제공해주는 interface라서 Spring에 의존적이라고 한다. 반면 @PostConstruct와 @PreDestroy는 Java가 전역적으로 제공하는 어노테이션이라 spring 의존성은 없다.
개인적인 견해이지만 Bean 생성, 파괴 조작을 할 때 제일 좋은 방법은 @PostContruct와 @PreDestroy를 사용하는게 아닐까 싶다. 따로 interface를 선언할 필요도 없고, Spring에 의존적이지 않으면서 그냥 annotation만 써주면 된다. 그리고 작동 원리도 어렵지 않고 직관적이다. BeanLife Cycle과 연관된 기능들을 찾아보고 다녔더니 나처럼 단순DB 캐싱을 위한 선호출 말고도 멋진 방법으로 사용하는 예제가 많았어서 다음번에는 Lazy Initalization에 다뤄볼 것이다.
'개발 > Backend' 카테고리의 다른 글
[Spring] @SpringBootApplication과 @ComponentScan (0) | 2020.03.17 |
---|---|
[Spring] applicationContext를 이용하여 존재하는 bean 가져오기 + Runner.java (0) | 2020.03.17 |
[Spring] PSA란 무엇인가? (2) | 2020.03.05 |
[Spring] IoC 컨테이너와 Bean, DI (0) | 2020.02.23 |
[Spring] @annotaion으로 Spring AOP 기능 구현 (0) | 2020.02.18 |