在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
在尝试设置断点时,我在Eclipse中得到这个奇怪的错误。
Unable to insert breakpoint Absent Line Number Information
我勾选了编译器选项的复选框,但运气不好。
当前回答
确保运行时的主类所在的项目与包含断点的类所在的项目相同。如果不是,请确保两个项目都在运行配置的类路径中,并且出现在任何jar和类文件夹之前。
其他回答
在使用Spring Tool Suite (STS)启动Java EE项目时,我们也会遇到这个消息,但是我们可以忽略这个消息,因为一切都很好。
在调试部署到Tomcat的WAR(由多个Eclipse项目构件构造)时,我遇到了同样的问题。
我正在使用ANT构建脚本构建所有内容。如果这是您正在做的事情,请确保在您获得的每个javac ant任务上设置了debug=true标志。这是我唯一的问题-我希望它能帮助你的问题!
如果您确实指出了您正在使用的eclipse版本和技术(例如,Java JDT,或面向Java的AJDT,或c++ CDT),这将有所帮助。
在Java方面,我猜想您的“勾选编译器选项中的复选框”指的就是这个
在“窗口—>首选项—> Java—>编译器—>类文件生成”下,所有“类文件”生成选项都设置为True:
(1)添加可变属性, (2) addline number, (3)添加源文件名, (4)保存未使用的局部变量。
您的项目是否只在全局级别(windows Preferences)或在项目特定级别检查这些?
你确定打开的类(你试图在上面设置断点):
是您的源代码之一(并且不是来自第三方库) 是。java,而不是。class?
尝试清理所有内容并重新构建所有内容,检查潜在的jar冲突。
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.
对于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");
}
}