Init method in Spring Controller (annotation version)
Solution 1:
You can use
@PostConstruct
public void init() {
// ...
}
Solution 2:
Alternatively you can have your class implement the InitializingBean
interface to provide a callback function (afterPropertiesSet()
) which the ApplicationContext will invoke when the bean is constructed.