Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlayFramework 2.6.x - Execute Application Startup Code

This question is with regard to play! java 2.6.x

I am attempting to bootstrap some initialization code which needs to be executed during application startup

As per documentation, I have a class called Module in root package

  public class Module extends AbstractModule {

  private final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("application");

  @Override
  public void configure() {
    logger.info("Loading Modules");
    bind(ConsumerBootstrap.class).asEagerSingleton();
  }

}

However it is not behaving as expected. The binding only occurs when I trigger a request on a specific route, rather than eager binding on application startup.

I am running the application using sbt run

Am I missing anything ?

like image 590
conikeec Avatar asked Jun 02 '26 20:06

conikeec


1 Answers

As said : This is by design. If you want to see it in action from sbt, run sbt testProd instead of sbt run.

like image 157
Igmar Palsenberg Avatar answered Jun 06 '26 03:06

Igmar Palsenberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!