You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code中Spring工具套件查看Java注解文档失败求助

解决VS Code中Spring Tool Suite无法查看注解文档的问题

原因分析

出现这个提示是因为VS Code没有关联到Spring相关依赖的源码包(sources jar),只能通过反编译生成stub代码,自然看不到官方的文档注释。

解决方法

1. 手动下载依赖源码包

  • 若使用Maven,在项目pom.xml中添加源码下载插件配置:

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.6.0</version>
          <executions>
            <execution>
              <id>download-sources</id>
              <goals>
                <goal>sources</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
    

    执行命令:mvn dependency:sources 完成源码下载。

  • 若使用Gradle,在项目build.gradle中添加配置:

    tasks.withType(JavaCompile) {
      options.compilerArgs += ['-parameters']
    }
    
    dependencies {
      implementation sourceSets.main.allJava
    }
    

    执行命令:gradle downloadSources 下载源码。

2. 配置VS Code关联源码

  • 打开VS Code设置(快捷键Ctrl+,),搜索java.configuration.runtimes,确认JDK配置正确且关联了对应源码路径。
  • 检查java.dependency.packagePresentation设置,确保未屏蔽源码显示。

3. 刷新项目依赖与缓存

  • 打开左侧「Java Projects」面板,右键点击项目名称,选择「Refresh Gradle/Maven Projects」重新加载依赖。
  • 按Ctrl+Shift+P执行「Java: Clean Java Language Server Workspace」命令,清除缓存后重启VS Code。

4. 更新Spring Tool Suite插件

在VS Code扩展市场搜索「Spring Tool Suite」,确保插件为最新版本,过时版本可能存在源码关联bug。


内容的提问来源于stack exchange,提问作者IshAsh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 13:00:56