Playframework run and Global.onStart
When i run application in DEV mode (play run) my Global.onStart method is not executed. But if i "play start" my application then Global.onStart runs as it should.
How can i execute Global.onStart by "play run"ing it ?
I use the java version 2.0.2
In dev mode, onStart is called with the first request
That was the answer for my question - thank you!
在全局对象中添加方法时,可能必须杀死当前的应用程序并重新启动它以便重新加载更改。
In case you do not have application.mode
specified in your conf file, starting the application using play run
and play start
triggers dev
and prod
modes respectively play docs.
That said, and taking into account the differences between the modes (more details here), namely
Play starts the application immediately (including any bootstrap jobs), rather than waiting for the first request, again adding a small performance benefit for first use
you might want either play start
or change the mode to PROD in your config file.