eclipse出现Unable to evaluate the selected expression解决办法

现象:

我的eclipse版本是Version: Photon Release (4.8.0),在调试spring boot源码过程中遇到如下问题:

选中某个变量Ctrl+Shift+I查看变量内容的时候,总是弹出如下对话框:

 

 Unable to evaluate the selected expression:

To Perform an evaluation, an expression must be compiled in the context of a java project's build path. The Current execution context is not associated with a java project in the workspace.

另外在expressions的viewer中也无法查看变量值  

分析:

双击Breakpoints Viewer里面的断点,打开的Class File Viewer,请注意我用黄色高亮显示的部分:

 

 

 

 

 

从 Debug Viewer,双击顶部的调用栈项,实际显示的Source Viewer

 

 经过对比发现,调用栈错误的关联了source code,并没有关联Class File。Source Code Viewer并没有调试的上下文信息,所以造成了Unable to evaluate the selected expression错误。初步分析应该是eclipse版本Version: Photon Release (4.8.0)这个版本的jdt有错误。

 

如何解决

临时解决办法1:

选中Debug viewer窗口中,选中该工程->右键选中Edit Source Lookup...

 

 

勾选Search for Duplicate source files on the path

 

 

 

重新运行程序走到断点处系统会自动弹出如下对话框,选择对应的.class文件,调试就可以关联到class File Viewer类中了

 

 

选中某个变量,ctrl+shift+I 就可以正常查看spring boot的源码了。

 

 

 

办法2:

升级或者降级eclipse版本,我试了oxgen是可以正常运行的。

 

注意:网上另外一篇文章 https://blog.csdn.net/hehuihh/article/details/82589107 并没有解决我的问题,虽然看到的现象是一样的。

 

posted on 2020-03-03 00:31  pmh905001  阅读(1524)  评论(0编辑  收藏  举报

导航