Spring ApplicationListener is not receiving events

У меня есть следующий ApplicationListener:

package org.mycompany.listeners;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextStartedEvent;

public class MyApplicationListener implements ApplicationListener<ContextStartedEvent> {

  public MyApplicationListener() {
    super();
    System.out.println("Application context listener is created!");
  }

  /**
   * {@inheritDoc}
   */
  public void onApplicationEvent(final ContextStartedEvent event) {
    System.out.println("Context '" + event.getApplicationContext().getDisplayName() + "' is started!");
  }

}

И следующее определение bean-компонента:

<bean name="myApplicationListener" class="org.mycompany.listeners.MyApplicationListener" />

Я вижу, что bean-компонент создается при выводе сообщения из конструктора, но событие запуска контекста никогда не принимается. Что мне не хватает?

39
задан Brian Tompsett - 汤莱恩 12 June 2015 в 09:22
поделиться