英文:
How do I get lombok to work with Visual Studio Code?
问题
我在vscode中有一个Java Gradle项目,我按照网站上的说明使用了Gradle插件和vscode的lombok扩展。然而,vscode仍然无法解析lombok.Data的Java导入。我错过了什么?
英文:
I have a java gradle project in vscode, and I followed the instructions on the site to use the gradle plugin and the vscode lombok extension. However, vscode is still unable to resolve the lombok.Data java import. What am I missing?
答案1
得分: 14
原来我必须在VS Code中运行以下命令:
> Java: 清理Java语言服务器工作区
英文:
Turns out I had to run the following command in VS Code:
> Java: Clean the Java language server workspace
答案2
得分: 9
使用下一个插件 Lombok Annotations Support for VS Code
英文:
Use next plugin Lombok Annotations Support for VS Code
答案3
得分: 0
尝试排除传递性依赖以获得更好的控制
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
我正在使用VSCode编辑器,尝试从扩展窗口中添加lombok。之后清理工作区,这对我起作用。
英文:
Try to exclude transitive dependency for better control
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
I am using VScode editor try to add lombok for from the extension window. After that clean the workspace it worked for me.
答案4
得分: 0
截至2022年12月,根据此公告 https://devblogs.microsoft.com/java/java-on-visual-studio-code-update-december-2022/ ,引用:「从7月开始,我们的Java扩展可以直接支持使用Lombok的项目,无需安装任何额外的扩展。」
当然,Lombok必须在您的类路径中,可以作为jar文件或作为构建工具配置(如maven或gradle)的一部分。
设置:
但必须在设置中启用它。我不确定默认是否已启用。此截图显示了如何启用。
英文:
As of Dec. 2022, according to this announcement https://devblogs.microsoft.com/java/java-on-visual-studio-code-update-december-2022/ , quote: "Starting in July, our Java extensions can directly support projects that are using Lombok without installing any additional extensions."
Of course, lombok must be in your classpath, either as a jar or part of a build tool configuration like maven or gradle.
Setup:
It must be enabled in settings though. I'm not sure if it is by default. This screenshot shows how to enable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论