现象
用vscode写java代码的时候突然出现,修复问题点击Ctrl时,输出窗口就打日志,报错Request textDocument/definition failed。
我百度唯一的有用线索就是这个报错有一个关于js的报错也是输出的Request textDocument/definition failed。 有一个回答就是说"这是一个bug,等待解决"。Spring Boot Tools当前的版本是1.8.0.我回退到1.7.0,成功了错误
[Error - 下午8:28:20] Request textDocument/definition failed.Error: The received response has neither a result nor an error property. at handleInvalidMessage (C:\**省略*\.vscode\extensions\pivotal.vscode-spring-boot-1.8.0\node_modules\vscode-jsonrpc\lib\main.js:517:40) at processMessageQueue (C:\**省略*\.\.vscode\extensions\pivotal.vscode-spring-boot-1.8.0\node_modules\vscode-jsonrpc\lib\main.js:266:17) at Immediate.setImmediate (C:\**省略*\.0\.vscode\extensions\pivotal.vscode-spring-boot-1.8.0\node_modules\vscode-jsonrpc\lib\main.js:247:13) at runCallback (timers.js:696:18) at tryOnImmediate (timers.js:667:5) at processImmediate (timers.js:649:5)
解决方式
我尝试回退Spring Boot Tools至1.7.0,问题解决了。
我再次升级版本值1.8.0问题浮现更新日志
## 2019-06-21 (4.3.0 RELEASE)* *(Spring Boot)* improvement: project classpath notifications now happen in batch on startup to further optimize performance and job load on the Eclipse side* *(Spring Boot)* improvement: symbols are now being re-created if dependent types change* *(Spring Boot)* fixed: Slow code completion takes more than a 1 sec. ([#293](https://github.com/spring-projects/sts4/issues/293 "https://github.com/spring-projects/sts4/issues/293"))* *(Spring Boot)* fixed: content-assist for Spring XML config files now working again in VS Code and Theia* *(Spring Boot)* fixed: ClassCast Exception in Boot LS while application.yml file opened in the editor* *(Spring Boot)* fixed: Anonymous inner type beans don't have boot hints## 2019-05-24 (4.2.2 RELEASE)* *(all language servers)* performance: additional improvements to language server startup time* *(Spring Boot)* new: additional fine-grained preferences for Spring XML config file support* *(Spring Boot)* new: navigation for bean identifiers, bean classes, and property names for Spring XML config files* *(Spring Boot)* new: content-assist rolled out for many more Spring XML config elements and attributes* *(Spring Boot)* new: live bean information now showing up in types from class files (when source code is shown) - *VSCode and Theia only at the moment** *(Spring Boot)* improvement: hugely improved content-assist for bean class attribute in Spring XML config files (incl. package name proposals and vastly improved performance)* *(Spring Boot)* improvement: property name content-assist in Spring XML config files now shows proposals from properties defined in supertypes, too* *(Spring Boot)* improvement: symbol scanning skips output folders now
结语
对于官方的版本也出现这样的bug,我觉得开源也不是良药,有的时候会在生产和工作中带来负面后果。稳定反而更迫切!