Search code examples
javamavenpom.xmlmaven-plugincannot-find-symbol

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


I am using Intellij Idea to build a java maven project from a MAC OS machine. When I am trying to run 'compile' an error is issued:

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

A line with this error (it works correctly):

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

In Google, I found only information that such an error began to appear with JDK7. Everything works great with JDK6. But I still do not understand how to solve this.

my 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>

I saw a question similar to mine, but it didn’t help me


Solution

  • How I solved the problem:

    Added a dependency in pom for the library from which the FieldUtilsExt.getFieldsWithAnnotation (...) method was used