0

在我的应用程序中,我使用注释来标记我希望在应用程序的“onStart”挂钩期间执行的一些方法。我的代码是这样的:

@Override
public void onStart(Application app) {
    Reflections reflections = new Reflections("", new SubTypesScanner(false), new MethodAnnotationsScanner(), app.classloader()); //also tried without classloader
    Set<Method> onStartMethods = reflections.getMethodsAnnotatedWith(OnStart.class); //OnStart is my annotation

    if (CollectionUtils.isNotEmpty(onStartMethods)) {
        for (Method osm : onStartMethods) {
            // execute the methods
        }
    } else {
        // I CRASH the server because this is not a behaviour I want
    }

}

有一点这工作 FLAWLESSSLY 两者都使用play runplay start但如果我使用它就不再工作了play dist。该错误发生在我们的测试服务器(EC2 ubuntu 13.10)和我的开发机器(Ubuntu 14.04LTS)上。

我用它在我的机器上进行测试。

$alias testdeploy
alias testdeploy='play compile && play dist && unzip -o target/universal/*.zip -d ~/test-deploy/ && bash ~/test-deploy/server_crm-1.0/bin/server_crm'

我正在将 Java7 与 Play 一起使用!2.2. 我需要一些见解。发生了什么事......最重要的是我该如何解决这个问题?

更新:当然我也测试play stage过......结果与dist

4

1 回答 1

1

使用 "" 启动反射有效地扫描从 ClasspathHelper.forPackage("") 获得的 url。

您可能希望在运行时检查不同部署环境中的这些 url,并使用正确的参数而不是“”。

否则使用其他 ClasspathHelper.forXXX 来获取正确的 url。

于 2014-04-29T09:16:38.263 回答