PlayFramework 2.6.x-执行应用程序启动代码 [英] PlayFramework 2.6.x - Execute Application Startup Code
问题描述
这个问题是关于玩的! Java 2.6.x
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
根据文档,我在根包中有一个名为Module的类
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.
我正在使用sbt run
我错过了什么吗?
推荐答案
如上所述:这是设计使然.如果您想从sbt看到它在运行,请运行sbt testProd而不是sbt run.
As said : This is by design. If you want to see it in action from sbt, run sbt testProd instead of sbt run.
这篇关于PlayFramework 2.6.x-执行应用程序启动代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!