为什么 Maven 错误 'java: cannot find symbol'?

Why in Maven Error 'java: cannot find symbol'?

我正在使用 Intellij Idea 从 MAC OS 机器构建一个 java maven 项目。当我尝试 运行 'compile' 时出现错误:

Error:(120,41) java: cannot find symbol

出现此错误的一行(它工作正常):

for (Field field : FieldUtilsExt.getFieldsWithAnnotation(PageFactory.getInstance().getCurrentPage().getClass(), ElementTitle.class))

在Google中,我只找到了JDK7开始出现这种错误的信息。一切都适用于 JDK6。但是我还是不明白怎么解决。

我的POM.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">

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <aspectj.version>1.8.10</aspectj.version>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${allure.results.directory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/test/resources</directory>
                                    <includes>
                                        <include>allure.properties</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <junitArtifactName>junit:junit</junitArtifactName>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>
                         -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                         -Dcucumber.options="--tags ${TAGS} --plugin io.qameta.allure.cucumber2jvm.AllureCucumber2Jvm"
                         -Dfile.encoding=UTF-8 -Xmx1024m -XX:MaxPermSize=256m -DIGNITE_QUIET=true
                    </argLine>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>io.qameta.allure</groupId>
                        <artifactId>allure-maven</artifactId>
                        <version>2.9</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

</project>

我看到一个 question 和我的相似,但对我没有帮助

我是如何解决问题的:

在 pom 中为使用 FieldUtilsExt.getFieldsWithAnnotation (...) 方法的库添加了依赖项