简体   繁体   中英

How do I get lombok to work with Visual Studio Code?

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?

Turns out I had to run the following command in VS Code:

> Java: Clean the Java language server workspace

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.

A note appeared on the VS Code Lombok plugin:

Starting from 1.8.0, the Language Support for Java(TM) by RedHat extension has built-in support for Lombok and automatically uses the lombok.jar from your project classpath. The embedded lombok.jar in the vscode-lombok extension will be deprecated in favor of RedHat Java extension.

There's a settings in settings.json to control this feature:

"java.jdt.ls.lombokSupport.enabled": true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM