Playframework 2.0 如何使用activator调试播放应用程序?

Playframework 2.0 如何使用activator调试播放应用程序?,playframework-2.0,typesafe-activator,Playframework 2.0,Typesafe Activator,我知道对于经典的Play框架,它是Play debug~run。我尝试运行activator debug~run,但出现以下错误: [error] Not a valid command: debug (similar: idea) [error] Not a valid project ID: debug [error] Expected ':' (if selecting a configuration) [error] Not a valid key: debug (similar: de

我知道对于经典的Play框架,它是Play debug~run。我尝试运行activator debug~run,但出现以下错误:

[error] Not a valid command: debug (similar: idea)
[error] Not a valid project ID: debug
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: debug (similar: debianSign, node)
[error] debug
[error]      ^
我做错了什么?

如果您只是在运行activator~run,那么您应该能够通过以下方式传递JVM调试端口选项:

./activator -jvm-debug <port> ~run
这可能与play run的功能不同,但下面是它添加到命令行的参数:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<port>
发件人:

我已在IDE中成功地附加到此进程

如果您在windows中运行,则自动配置会有所不同。使用最新的activator,您可以执行以下操作:

打开%UserProfile%\.activator\activatorconfig.txt根据您的windows安装,用户配置文件会有所不同。我的一个安装是C:\Documents and Settings\jsuereth,另一个安装是C:\Users\jsuereth。超过文件中的以下内容: -Xdebug -Xrunjdwp:transport=dt_套接字,server=y,suspend=n,地址= 您可以在启动activator之前在命令行上设置JAVA_OPTS属性,例如:。 设置JAVA_OPTS=-Xdebug-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=
希望有帮助

我有windows7和activator 1.2.12,上面的答案对我来说不适用。相反,我使用了项目主文件夹的activator.bat命令的-jvm调试选项,它成功了。像这样:

C:\Projects\MyProject>activator -jvm-debug Listening for transport dt_socket at address: 9999 [info] Loading global plugins from C:\Users\MyAccount\.sbt\0.13\plugins [info] Loading project definition from C:\Projects\MyProject\project [info] Set current project to MyProject (in build file:/C:/Projects/MyProject/) [MyProject] $ run --- (Running the application, auto-reloading is enabled) --- [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 'force' enabled (Server started, use Ctrl+D to stop and go back to the console...) Running "watch" task 然后,在activator sbt中,我使用了run命令。像这样:

C:\Projects\MyProject>activator -jvm-debug Listening for transport dt_socket at address: 9999 [info] Loading global plugins from C:\Users\MyAccount\.sbt\0.13\plugins [info] Loading project definition from C:\Projects\MyProject\project [info] Set current project to MyProject (in build file:/C:/Projects/MyProject/) [MyProject] $ run --- (Running the application, auto-reloading is enabled) --- [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 'force' enabled (Server started, use Ctrl+D to stop and go back to the console...) Running "watch" task
要从eclipse进行调试,请右键单击该项目并选择debug As,debug Configuration。在“调试配置”对话框中,右键单击远程Java应用程序并选择“新建”。将端口更改为9999,然后单击应用。从现在起,您可以单击Debug连接到正在运行的应用程序。

我尝试了Readren的解决方案,但使用了IntelliJ IDEA社区版,因此没有内置的Play支持而不是Eclipse

这基本上就是我使用1.3.2的新类型安全激活器的文档记录方式。对我来说,应用程序运行了,IntelliJ调试器看起来正在连接,但它不会命中任何断点。IntelliJ中的断点也没有一个记号,表示它们不会被命中

我尝试更改activator.bat文件中的DEBUG_OPTS设置,以使用jdwp命令行参数的-agentlib形式,这似乎为我解决了这个问题

rem set DEBUG_OPTS=-Xdebug -Xrunjdwp:tnsport=dt_socket,server=y,suspend=n,address=!JPDA_PORT!
set DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999
也许我应该把它放在activatorconfig.txt的某个地方,但我花了大约4个小时试图让它工作-所以现在对我来说已经足够好了

我正在使用以下JVM,以备不时之需:

java版本1.7.0_75 JavaTM SE运行时环境构建1.7.0_75-b13
Java HotSpotTM 64位服务器VM build 24.75-b04,混合模式

我发现了另一件事:

fork in run := false

fork in Test := false
in build.sbt


这使您能够调试测试,而不仅仅是应用程序本身。

使用Play framework 2.x:

在项目目录中,运行activator命令,如下所示

activator-jvm调试9999运行

完成后,将项目作为IDE中的远程Java应用程序进行调试,以将其与activator进程挂钩


一旦完成此操作,您就可以在任何地方插入代码:

这是Activator中的一个错误:看起来该错误仅适用于Activator UI,而不是CLI。从Jenkins launcher中调用Activator CLI 1.2.2时,也会出现此问题,而不是在批处理或Shell构建中。您是在windows还是linux上?对于窗户,这是一个不同的钩子。啊!我在窗户上。我应该在windows上使用什么?很抱歉耽搁了这么久。关于1,我没有activatorconfig.txt。我甚至在我的C盘上搜索它。然而,对于2它工作!我终于可以调试了。非常感谢!这对我很管用。遗憾的是,在Play项目中没有引入activator时,没有像过去那样的速记符号。