为什么在Maven错误中"java:找不到符号"?



我正在使用Intellij Idea从MAC OS机器构建Java maven项目。当我尝试运行"编译"时,发出错误:

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

带有此错误的行(它工作正常(:

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

在谷歌中,我只找到了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>

我看到了一个与我类似的问题,但它对我没有帮助

我是如何解决问题的:

在 pom 中添加了对使用FieldUtilsExt.getFieldsWithAnnotation (...)方法的库的依赖关系

最新更新