ApplicationReadyEvent class

Published when the start is complete: every bean is created and every runner has finished.

This is the usual event for "do this once the application is up", such as filling a cache or announcing the service, without delaying the start. It goes through the context, so an @EventListener method of a bean receives it. It is not published when the context was closed by a runner. A listener that throws fails the run (the error is reported and the context closed) but no ApplicationFailedEvent is published.

@Component()
class Warmup {
  Warmup(this.catalog);
  final Catalog catalog;

  // After the start: requests can already be served meanwhile.
  @EventListener()
  void onReady(ApplicationReadyEvent event) => catalog.preload();
}

Spring (Java):

@EventListener
void onReady(ApplicationReadyEvent event) { catalog.preload(); }
Inheritance

Constructors

ApplicationReadyEvent(SpringApplication application, List<String> args, ConfigurableApplicationContext applicationContext, Duration timeTaken)
The event for application run with args; published by SpringApplication.

Properties

applicationContext → ConfigurableApplicationContext
The running context.
final
args → List<String>
The arguments of the run, as main received them.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
source → Object
The object that raised the event, usually the publishing bean (or the context, for the context's own events).
finalinherited
springApplication → SpringApplication
The application being started; the same object as source, with its type.
no setterinherited
timestamp → DateTime
When the event was created (not when a listener receives it).
finalinherited
timeTaken → Duration
The time from the beginning of run until the last runner finished.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited