Java EE annotations in Spring

Since I began programming I noticed that annotations kept gaining popularity. Implementing a marker interface is in many cases replace by adding an Annotation.

Even in Spring. Spring added the support tor the java EE annotations. Here’s a little example. Instead of implementing the initializingBean Interface, you can simply use theĀ @PostConstruct van Java EE 5.

All callback handler used in EE5+ are possible in Spring. you only have to configure theĀ CommonAnnotationBeanPostProcessor in your spring context.

/** {@inheritDoc} */
public void afterPropertiesSet() throws Exception {


/** Postconstuction method */
public void myMethod() {

It is a small nuance, but I personally like this way of working. I don’t chose annotations over interfaces in every case, but when we are talking about callback handlers, I think it the better way. Your implementation doesn’t include strange spring specific methods, but methods that make sense to you and your other developers. It just has a little annotation above it.