Playframework 应用程序启动时:无法找到标记有注释的方法,但只能在PROD模式下找到。为什么?
在我的应用程序中,我使用注释来标记我希望在应用程序的“onStart”钩子期间执行的一些方法。我的代码如下:Playframework 应用程序启动时:无法找到标记有注释的方法,但只能在PROD模式下找到。为什么?,playframework,playframework-2.2,reflections,Playframework,Playframework 2.2,Reflections,在我的应用程序中,我使用注释来标记我希望在应用程序的“onStart”钩子期间执行的一些方法。我的代码如下: @Override public void onStart(Application app) { Reflections reflections = new Reflections("", new SubTypesScanner(false), new MethodAnnotationsScanner(), app.classloader()); //also tried wit
@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
}
}
我正在用Java7玩游戏!2.2. 我需要一些洞察力。发生了什么事。。。最重要的是,我怎样才能解决这个问题
更新:当然我也测试了
play stage
。。。与使用“有效扫描从ClasspathHelper.forPackage(“”)获得的URL”启动反射时的dist结果相同
您可能希望在运行时检查不同部署环境中的这些URL,并使用正确的参数而不是“”
否则,请使用其他ClasspathHelper.forXXX获取正确的URL
$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'