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

Unable to insert breakpoint Absent Line Number Information

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


当前回答

我在Eclipse IDE中也有同样的错误。 但这似乎是一个可以忽略的错误。 我在错误对话框上按下Ok键,然后继续。 我的断点到达&我能够进一步调试。

其他回答

首先,我建议确定问题是与项目相关还是与单个测试文件相关。试着在调试模式下运行任何其他测试文件。

如果问题只适用于一个文件,这可能与自我嘲笑有关(就像我的情况一样)。否则,编译器/构建设置应该被更改。在之前的评论中已经描述过了。

我只是想强调一下。这已经足够我浪费时间在修复项目设置,而这是完全没有必要的:)

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

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

我试图调试日志管理器,需要将jre更改为jdk,然后在“主”选项卡中选择这个jdk,调试配置的“Java运行时环境”|“运行时jre”,然后一切正常。

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文件的版本,清理并重新编译源代码,最后刷新环境。我希望这能对其他人有用。

对于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");
   }
}