@PostConstruct

An annotation marking a bean method to run once, after dependency injection and before the bean is used.

In more detail

Use it to open resources the bean owns or validate required state; if it throws, startup fails with a useful message instead of leaving a half-ready bean. It comes from the Jakarta Annotations specification.

Example

@PostConstruct void open() { }

Related terms

Taught in

References