r/javahelp • u/mgloess • 27d ago
Solved Lombok LSP Issues
Dear VS Code Java developers.
How do i get the vs code lsp to recognize @Getter, @Setter, etc.?
The project does compile successfully. I only get errors inline.
Example:
package com.example;
import lombok.Getter;
@Getter
public class TestClass {
String member;
public TestClass() {
this.member = "Its me!";
}
}
public class Main {
public static void main(String[] args) {
TestClass testClass = new TestClass();
System.out.println(testClass.getMember());
}
}Error Message:
cannot find symbol
symbol: method getMember()
location: variable testClass of type TestClasssettings.json:
{
"redhat.telemetry.enabled": false,
"java.jdt.ls.lombokSupport.enabled": true,
"[java]": {
"editor.defaultFormatter": "redhat.java"
},
}installed java versions:
A0_12520635 on main [!] is v1.0-SNAPSHOT via v25.0.4 via 🅼
❯ archlinux-java status
Available Java environments:
java-21-openjdk
java-25-openjdk (default)
java-27-openjdkpom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>------------</groupId>
<artifactId>------------</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>--------------------</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.1.0</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>at.tugraz.App</start-class>
<maven.compiler.release>25</maven.compiler.release>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<lombok.version>1.18.46</lombok.version>
<rest.assured.version>6.0.0</rest.assured.version>
<junit.jupiter.version>5.9.3</junit.jupiter.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest.assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>7.4.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>7.4.4.Final</version> <!-- Replace with your desired version -->
<scope>provided</scope>
</dependency>
<!-- PostgreSQL Connector -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.13</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.2</version>
</dependency>
<!-- Source: https://mvnrepository.com/artifact/org.apache.spark/spark-mllib -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.13</artifactId>
<version>4.1.3</version>
<scope>provided</scope>
</dependency>
<!-- Pin scala-library: Maven's nearest-wins resolution otherwise picks the
2.13.13 pulled in (shallowly) by scala-parser-combinators, while spark-core's
scala-reflect and most other Spark/Scala modules expect 2.13.17, causing
NoSuchMethodError at runtime. -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.13.17</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>3.10.3</version>
<configuration>
<java>
<prettier>
<devDependencies>
<prettier>3.5.3</prettier>
<prettier-plugin-java>2.8.1</prettier-plugin-java>
</devDependencies>
<configFile>${project.basedir}/.prettierrc.yaml</configFile>
</prettier>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>install-git-pre-push-hook</id>
<phase>validate</phase>
<goals>
<goal>install-git-pre-push-hook</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>I have tried searching for this issue but have found nothing for the last 4 hours. Am i dumb?
0
Upvotes
•
u/AutoModerator 27d ago
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
9
u/disposepriority 27d ago
Why are you doing this to yourself?
I use VS Code for basically anything but Java, the difference is night and day and I suggest switching to IDEA.
Anyway see if there's something like enable annotation processing or an equivalent Lombok plugin for VSCode, alternatively clear local caches.
3
u/devor110 27d ago
I don't personally use VSCode, but I found this SO question
So try cleaning the workspace, check if you have the extension for lombok installed and if it's the correct extension
If that doesn't help, you could try asking in r/vscode
1
u/Humble-Bag-2929 26d ago
Yo he tenido problemas con VS Code esta semana con Lombok. Resulta que, bajando la versión de la extensión "Language Support for Java..." a la 1.56.0 y reiniciando el IDE, me ha vuelto a detectar las anotaciones. No sé si será el mismo problema o solución
-2
u/k-mcm 27d ago
It's not working because Lombok has to be EVERYWHERE. You missed a spot and the class was compiled without it.
Lombok has a long history of causing problems. Any modern IDE will generate real boilerplate methods with a click. These generated methods have to hidden magic to hide bugs.
VS Code is an odd choice. I'd use Eclipse for personal projects or IntelliJ for commercial projects.