According to the error information you providejava: Symbol not found Symbol: Variable log Location: Class
, it looks like you are using Lombok@Slf4j
I encountered a problem with annotation. This annotation is usually used to automatically create a SLF4J logger variablelog
. If the compiler cannot find thislog
Variables, which may be due to one of the following reasons:
-
Lombok dependency not added correctly: Make sure that the correct Lombok dependency is already included in your project and that the dependency is the latest version. For example, in Maven
There should be the following dependencies in the file:
<dependency> <groupId></groupId> <artifactId>lombok</artifactId> <version>1.18.24</version> <!-- Make sure this is the latest stable version --> <scope>provided</scope> </dependency>
Annotation Processors not enabled: In IntelliJ IDEA, you need to make sure Annotation Processors is enabled. You can set it through the following path:
File -> Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors
, and then check the "Enable annotation processing" option.Lombok plug-in installation: Make sure that the Lombok plugin is already installed in your IDEA. This can be accessed by
File -> Settings -> Plugins
Search and install the Lombok plugin to complete.JDK version issues: Make sure you are using a JDK version at least 1.8 or above, because some Lombok features may not support earlier JDK versions.
-
maven-compiler-plugin configuration: If your project is used
maven-compiler-plugin
, please check whether its configuration is correct. For example, make sure it points to the correct Java version and includes the Lombok dependency:<build> <plugins> <plugin> <groupId></groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> <annotationProcessorPaths> <path> <groupId></groupId> <artifactId>lombok</artifactId> <version>1.18.24</version> </path> </annotationProcessorPaths> </configuration> </plugin> </plugins> </build>
Reimport and build projects: Sometimes simple reimporting Maven projects or cleaning and rebuilding projects can solve this kind of problem. You can try running
mvn clean install
Commands to clean up and rebuild your project.Other potential reasons: There may also be problems caused by some conflicts in the classpath or the incompatible version of Lombok with your environment. In this case, it may be helpful to try updating to the latest Lombok version or to fall back to a known stable version.
To sum up, you should first check each of the above aspects to determine which link is wrong. Once the specific reasons are determined, corresponding measures can be taken to solve the problem. If the problem persists after all these steps are performed, it may be necessary to further investigate the configuration of the project or consider whether there are other environmentally-related issues.
Summarize
Here is the article about how to solve the error information encountered. java: Symbols cannot be found. This is the article about the article about the variable log. For more related java: Symbols cannot be found. Symbols: Variable log content, please search for my previous article or continue browsing the related articles below. I hope everyone will support me in the future!