调试与play框架激活器,scala和eclipse不工作



有很多关于这个的帖子,说明很直接,但是对于我的生命,我无法让调试器在断点处停止。

我的环境是

    <
  • eclipse 4.4.1/gh>scala 2.11
  • scala IDE 4.1.0.nightly play framework 2.3.3
  • 支持Scala IDE 0.4.6

启动激活器

activator -jvm-debug 9999 run

我设置了一个远程java应用程序调试配置与标准套接字附加。调试配置运行,连接到远程并启动一堆sbt线程。

但是,它不会在调试器中停止!这似乎并不难,我做错了什么?

编辑:我在一个项目中遇到了这个问题,我已经工作了一段时间,在一个全新的,未触碰的play-anguale-require-seed项目实例中。这是构建。该项目的SBT:

import WebKeys._
// TODO Replace with your project's/module's name
name := """play-angular-require-seed"""
// TODO Set your organization here; ThisBuild means it will apply to all sub-    modules
organization in ThisBuild := "your.organization"
// TODO Set your version here
version := "2.3.7-SNAPSHOT"
// Scala Version, Play supports both 2.10 and 2.11
//scalaVersion := "2.10.4"
scalaVersion := "2.11.4"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
// Dependencies
libraryDependencies ++= Seq(
  filters,
  cache,
  // WebJars (i.e. client-side) dependencies
  "org.webjars" % "requirejs" % "2.1.14-1",
  "org.webjars" % "underscorejs" % "1.6.0-3",
  "org.webjars" % "jquery" % "1.11.1",
  "org.webjars" % "bootstrap" % "3.1.1-2" exclude("org.webjars", "jquery"),
  "org.webjars" % "angularjs" % "1.2.18" exclude("org.webjars", "jquery")
)
// Scala Compiler Options
scalacOptions in ThisBuild ++= Seq(
  "-target:jvm-1.7",
  "-encoding", "UTF-8",
  "-deprecation", // warning and location for usages of deprecated APIs
  "-feature", // warning and location for usages of features that should be                 imported explicitly
  "-unchecked", // additional warnings where generated code depends on assumptions
  "-Xlint", // recommended additional warnings
  "-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver
  "-Ywarn-value-discard", // Warn when non-Unit expression results are unused
  "-Ywarn-inaccessible",
  "-Ywarn-dead-code"
)
//
// sbt-web configuration
// https://github.com/sbt/sbt-web
//
// Configure the steps of the asset pipeline (used in stage and dist tasks)
// rjs = RequireJS, uglifies, shrinks to one file, replaces WebJars with CDN
// digest = Adds hash to filename
// gzip = Zips all assets, Asset controller serves them automatically when client accepts them
pipelineStages := Seq(rjs, digest, gzip)
// RequireJS with sbt-rjs (https://github.com/sbt/sbt-rjs#sbt-rjs)
// ~~~
RjsKeys.paths += ("jsRoutes" -> ("/jsroutes" -> "empty:"))
//RjsKeys.mainModule := "main"
// Asset hashing with sbt-digest (https://github.com/sbt/sbt-digest)
// ~~~
// md5 | sha1
//DigestKeys.algorithms := "md5"
//includeFilter in digest := "..."
//excludeFilter in digest := "..."
// HTTP compression with sbt-gzip (https://github.com/sbt/sbt-gzip)
// ~~~
// includeFilter in GzipKeys.compress := "*.html" || "*.css" || "*.js"
// excludeFilter in GzipKeys.compress := "..."
// JavaScript linting with sbt-jshint (https://github.com/sbt/sbt-jshint)
// ~~~
// JshintKeys.config := ".jshintrc"
// All work and no play...
emojiLogs

fork in run := true

Kris的评论有答案!从构建中删除运行中的分支。SBT或设置为false。我不确定是否会有下游后果。

当您的scala应用程序不总是遵循java的包和目录结构之间的一对一关系时,也可能错过断点。

今天在一个游戏框架应用程序中遇到了这个问题。按照惯例,游戏控制器位于controllers包中。随着项目的增长,它被重构成几个不同的子项目。因此,controllers目录仍然保留,但是包被更改为package controllers.foo,这在scala中工作得很好。

与OP一样,尽管有简单的文档,但没有任何工作,调试器永远不会遇到断点。一旦我将测试控制器移动到一个与包布局匹配的目录中,瞧,命中了断点!

对于那些没有使用activator的用户,这将启动一个sbt调试会话:

java -debug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999 -jar ~/bin/sbt-launch.jar "$@"

然后在play console中运行run。切换到Eclipse并选择:

  • Run> Debug Configurations

  • 添加新的远程Java应用程序

  • 选择Standard (Socket Attach)或Scala Debugger (Socket Attach)

  • host: localhost, port: 9999

  • 单击应用;然后点击Debug

如果一切顺利,当您访问在其依赖链中某处设置了断点的控制器时,应该会击中断点,从而允许您按预期的方式逐步执行代码。

  1. 尝试在正常模式下运行并复制粘贴到编辑器中您的控制台日志的前两行。
  2. 在调试模式下做同样的操作
  3. 比较:
    • 在第一行,在调试模式下(不是在正常情况下),你应该有这个(与suspend=y):
      agentlib: jdwp = = dt_socket,运输地址= 127.0.0.1:xxxxx,暂停= y , server = n
    • 在调试模式下(不是在正常模式下)第二行应该出现:
      已连接到目标虚拟机,地址:'127.0.0.1:xxxxx',传输:'socket'

suspend=y使您的服务器等待连接。可以是n

  • 检查远程调试器的配置,检查用于侦听的主机(localhost)和端口(9999),以及其他一些选项(传输等)。它应该与启动器中的匹配。
  • 最新更新