0

I have created a class which implements two interfaces.

I have used a init method with @postconstruction annotation

I am observing that though bean is initialised only during start up, init method is called multiple times.

Async Code
  • 51
  • 9

1 Answers1

0

The @PostConstruct method will be called every time the bean is instantiated. This means either every time you do a "new", or, if you've registered your class with a @Service, @Repository, or any other anotation of sorts that registers the class as a spring bean, the first time you @Autowired it.

Watch out for instantations of the class aside from those if you are using another framework annotations like @ManagedBean in JSF, which could be instantiating your class without you realising it.

Jorge.V
  • 1,329
  • 1
  • 13
  • 19