在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。

Unable to insert breakpoint Absent Line Number Information

我勾选了编译器选项的复选框,但运气不好。


当前回答

这解决了我的问题:

窗口->首选项->服务器->运行时环境 Apache Tomcat ->编辑 选择JDK而不是JRE

其他回答

我从黑莓SDK方面得到了这个问题的答案:出于某种原因,无论我在编译器中修改了多少次选项,实际的底层设置文件都没有改变。

在项目的.settings文件夹中查找一个名为org.eclipse.jdt.core.prefs的文件。

在那里你可以手动修改设置:

org.eclipse.jdt.core.compiler.debug.lineNumber=generate

编辑:除此之外,我还注意到有时我可以忽略Eclipse给出的警告,它仍然会停在需要的地方……越来越奇怪……我将此归入我们作为开发人员所需要处理的事情中。

我在jetty服务器上使用ANT编译新的。war文件时也遇到了同样的问题。在你必须像之前写的那样设置Java compiler之后,你应该创建相同版本的jdk/jre编译器和构建路径(例如jdk 1.6v33, jdk 1.7, ....)。

我什么都做了,还是没工作。解决方案是删除已编译的.class文件和生成的war文件的目标,现在它的工作:)

我尝试了之前的大部分解决方案,但还是遇到了问题。 这就是我接下来所做的:

从Eclipse中删除应用程序 停止服务器 从webapps中删除应用文件夹 从服务器中的临时文件夹中删除内容 从服务器中的工作文件夹中删除内容 在Eclipse上重新打开应用程序 启动服务器

可能有些步骤是不需要的,但“以防万一”。

因此,如果前面的解决方案仍然不适合你。试试这个。 我希望这对你有所帮助;-)

确保运行时的主类所在的项目与包含断点的类所在的项目相同。如果不是,请确保两个项目都在运行配置的类路径中,并且出现在任何jar和类文件夹之前。

这里有详细的解释:

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".