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

Unable to insert breakpoint Absent Line Number Information

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


当前回答

对于Spring相关的问题,考虑在某些情况下它生成的类“没有行号”;例如,一个没有接口的@Service注释类,添加接口就可以调试了。请参见这里的完整示例。

@Service("SkillService")
public class TestServiceWithoutInterface {
   public void doSomething() {
      System.out.println("Hello TestServiceWithoutInterface");
   }
}

上面的服务将有一个由spring生成的接口,导致“缺少行号”。添加一个真实的界面解决了生成问题:

public interface TestService {
    void doSomething();
}

@Service("SkillService")
public class TestServiceImpl implements TestService {
   public void doSomething() {
      System.out.println("Hello TestServiceImpl");
   }
}

其他回答

If someone is trying to debug Java's source code, then, this is the only solution that worked for me. Most of the above answers talk about setting the Compiler option to generate line numbers.But, if want to debug Java's source code (say java.util.HashMap), then the above options may not work for you. This is because , the project from where you intend to debug the source code is having the Java Build Path --> Library --> JRE System Library pointing to the jre jar instead of the jdk jar. The classes bundled inside jre jar have already been pre-compiled with a specific option, that will not honor the Compiler option settings. Solution, is to reconfigure your project to have the JRE System Library point to the jdk jar. The classes inside your jdk jar will honour the Compiler option settings. So, once you update your project's JRE System Library to point to the jdk jar, debug on Java source code will start working.

尝试更改您使用的jre。请设置JDK目录下的jre。

这招对我很管用:

在窗口——>首选项——> Java——>编译器——>类文件生成下,所有选项都必须为True。 在build.xml <javac>任务中使debug="true"。 通过ant生成的war在tomcat中部署应用程序 在Debug模式下重新启动Tomcat

在调试部署到Tomcat的WAR(由多个Eclipse项目构件构造)时,我遇到了同样的问题。

我正在使用ANT构建脚本构建所有内容。如果这是您正在做的事情,请确保在您获得的每个javac ant任务上设置了debug=true标志。这是我唯一的问题-我希望它能帮助你的问题!

检查/做以下事情:

1)在“窗口—>首选项—> Java—>编译器—>类文件生成”下,所有选项必须为True:

(1) Add variable attributes...
(2) Add line number attributes...
(3) Add source file name...
(4) Preserve unused (never read) local variables

2)在项目的.settings文件夹中,找到一个名为org.eclipse.jdt.core.prefs的文件。 验证或设置org.eclipse.jdt.core.compiler.debug.lineNumber=generate

3)如果仍然出现错误窗口,单击复选框不显示错误信息。

4)清洁和建造项目。开始调试。

正常情况下,错误窗口不再显示,调试信息显示正确。