在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
当前回答
在Eclipse中调试时如何修复断点错误? 只替换这几行。
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
其他回答
对于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");
}
}
从Spring AOP得到这个消息(似乎来自CGLIB库)。点击忽略似乎工作正常,我仍然可以调试。
因为我安装了6个不同版本的Java,所以我必须更改默认的JDK遵从性,以匹配我想使用的Java版本。当所有内容都使用Java 1.6构建/编译时,Eclipse默认将编译器遵从级别设置为Java 1.7。
所以我所做的就是
在eclipse菜单中,进入“窗口->首选项->Java->编译器” 在JDK遵从性下,我将编译器遵从性级别从1.7更改为1.6
现在Eclipse不再抱怨“无法插入缺少行号信息的断点”,并且调试断点实际上工作了!!
有一次我在使用junit和Mockito时遇到了同样的错误,我忘记为静态类添加@PrepareForTest。
添加以下代码修复了我的问题。
@PrepareForTest({XXXXX.class})
不确定是不是同一个案子。
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文件的版本,清理并重新编译源代码,最后刷新环境。我希望这能对其他人有用。