在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
当前回答
We have very useful information to solve this problem already, but in my specific case, the problem was that as I did an update to my project from the repository, new classes were generated with the compiled source from the newest code. The problem is that I forgot to change the versions of the projects in my POM files and as the breakpoints were set on the new code and the POM files were still pointing to old versions that were available on the JAR files of a previous compilation, the classes from the JAR files were chosen and not the classes from the new code.
在恢复中,为了解决这个问题,我只需要更新主项目的POM文件的版本,清理并重新编译源代码,最后刷新环境。我希望这能对其他人有用。
其他回答
我发现了这条信息的另一个原因。我在编程Scala。解决方案是:
打开运行->调试配置 在主选项卡的底部,在“应用”和“恢复”按钮旁边,有一个文本说明你正在使用哪个启动器,旁边有一个超链接说“选择其他”。这是一个奇怪的UI元素,乍一看并不可行。 使用“选择其他”链接并选择“Scala应用程序(新调试器)启动器”。另一个似乎不能与Scala一起工作。
现在调试应该可以工作了。注意,我已经安装了Scala IDE插件,如果您没有这个选项,那么这个选项可能是不可用的。
这里有详细的解释:
https://github.com/spring-projects/spring-ide/issues/78
只是为了将来参考,这是答案的相关部分(忽略引用Spring Boot应用程序的事实,在许多其他情况下行为是相同的):
Whenever you set a breakpoint in Eclipse/STS, the IDE tries to set the breakpoint in the VM if you launch an app. That is what happens in your case when you run the boot app in debug mode. For each class that gets loaded into the JVM, the IDE checks whether it needs to set a breakpoint or not. If it decides to set the breakpoint, the tries to do so (using the information from the breakpoint definition in the IDE, including its line number, since you usually set line breakpoints on a source file at a given line). This decision (whether to set the breakpoint on a given loaded class or not) checks the types that you set the breakpoint on, enclosing types, and inner classes. This makes sure that breakpoints for inner classes (even anonymous inner classes) are set to the JVM (and are not ignored). Spring Boot generates an inner class for your controller at runtime (this is the CGLIB generated inner class that appears in the error message). When the JVM loads that class, it tries to set the line number breakpoint of the enclosing type (for this inner class). Since the generated inner class doesn't have any line number information (it doesn't need to have line number information), setting the breakpoint fails for this inner class with the mentioned error message. When the IDE loads the enclosing type (your controller class itself), it also tries to set the line breakpoint and succeeds with that. This is visualized with the check marker on the breakpoint marker. Therefore you can safely ignore the error message that shows up. To avoid this error message to show up, you can go to the preferences (Java -> Debug) and disable "Warn when unable to install breakpoint due to missing line number attributes".
有一次我在使用junit和Mockito时遇到了同样的错误,我忘记为静态类添加@PrepareForTest。
添加以下代码修复了我的问题。
@PrepareForTest({XXXXX.class})
不确定是不是同一个案子。
以上这些都对我不起作用。 下面的解决方案终于奏效了。 调试配置->类路径->用户条目->(添加要调试的项目的src文件夹)
我的问题是我有2个JAR,我试图根据Eclipse中的Java Build Path => order & Export选项卡中的顺序覆盖另一个JAR,因为一个是用于调试的,另一个不是(调试JAR在顺序中是第一个)。当我这样做时,我必须手动附加一个源。
我尝试删除非调试JAR,并将调试JAR放在我的\WEB-INF\lib\目录中,进行清理、构建等操作,结果成功了。这一次(已经删除了附加的源代码),它将自动让我浏览调试代码,而无需手动附加任何源代码。断点和调试也可以工作。
为了防止有人仍然有问题,我也尝试了其他答案中提到的所有这些特解:
取消选中,应用并重新选中添加行号属性… 手动编辑org.eclipse.jdt.core.prefs,如另一个答案:https://stackoverflow.com/a/31588700/1599699中提到的 确保在启用调试的情况下生成JAR。 将JDK遵从级别从1.6更改为1.7(从而匹配我正在使用的JDK)。
我还做了通常的服务器关闭(并确保java.exe实际上是关闭的……),删除两个项目中的\build\目录,使用-clean参数重新启动Eclipse,重新创建调试JAR,刷新,清洗,并在其中构建带有调试JAR的项目,以调试模式启动服务器,发布/清洗,并设置断点。