PlayFramework 2.6.x - Execute Application Startup Code

≡放荡痞女 提交于 2019-12-12 18:19:27

问题


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 ?


回答1:


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



来源:https://stackoverflow.com/questions/46062618/playframework-2-6-x-execute-application-startup-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!