You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a `@PostConstruct` method is usually only done when field injection is used and initialization needs to be performed after that.
227
+
228
+
It's better to do this directly in the constructor with constructor injection, so that all logic will be encapsulated there.
229
+
This also makes using the bean in environments where JavaEE is not present - for example in tests - a lot easier, as forgetting to call the `@PostConstruct` method is no longer possible.
`@PreDestroy` should be replaced by implementing `AutoCloseable` and overwriting the `close` method instead.
249
+
250
+
This also makes using the bean in environments where JavaEE is not present - for example in tests - a lot easier, as forgetting to call the `@PreDestroy` method is no much more difficult.
0 commit comments