Java cannot find symbol solution

1. The project keeps reporting that the symbol cannot be found, resulting in failure to start.
insert image description here
2. Solution 1
: Clear the idea cache,
insert image description here
insert image description here
recompile, package and run.

3. Solution 2:
Delete the following files in the project folder
insert image description here
and reopen the maven clean package.

  1. Solution 3
    It may be that the jdk version used when maven is compiled is incorrect, and it needs to be added to the pom file:
    the location is build -> plugins
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>11</source>
        <target>11</target>
    </configuration>
</plugin>

Guess you like

Origin blog.csdn.net/qq_38747892/article/details/131132138