Play 2启动方法无法执行Java

时间:2016-12-30 12:52:23

标签: java playframework-2.0 startup

我在Play 2.5应用程序中有一些代码在启动时执行。它在我的本地计算机上运行良好,但无法在生产服务器上执行。 以下是相关代码:

这是启动课程的构造函数:

@Inject
public StartupController(ActorSystem system, CreditCardChargeJob chargeJob, 
        ProductService productService, RoleService roleService) {

    Logger.info("Application startup...");

    this.system = system;
    this.chargeJob = chargeJob;
    this.productService = productService;
    this.roleService = roleService;

    fillDatabase();

    createCreditCardChargeJob();

}

这是定义绑定的模块:

public class Module extends AbstractModule {

   @Override
   protected void configure() {

       Logger.info("Binding on startup class...");

       bind(StartupController.class).asEagerSingleton();

   }

}

我在我的application.conf部分定义模块:

play.modules {
   enabled += be.objectify.deadbolt.java.DeadboltModule
   enabled += modules.CustomDeadboltHook
   enabled += modules.Module
} 

localhost上输出的日志是:

 [info] application - Binding on startup class...
 [info] application - Creating Pool for datasource 'default'
 [info] p.a.d.DefaultDBApi - Database [default] connected at    jdbc:mysql://localhost/creditperfection
 [info] application - Application startup...
 [info] application - ActorSystem: akka://application
 [info] application - Credit card charging job is running...

在服务器上只有这个:

 [INFO] from play.api.db.DefaultDBApi in main - Database [default] connected at jdbc:mysql://localhost/creditperfection
 [INFO] from play.api.Play in main - Application started (Prod)

因此,正如您可以从日志控制器中看到的,应该在启动时执行的控制器由于某种原因未能运行 似乎问题不在代码中,因为它适用于localhost,我真的坚持使用它。如果有人至少知道什么可能导致这种行为,请告诉我你的想法。

感谢您的帮助! 维塔利

0 个答案:

没有答案