maven “cannot find symbol” message unhelpful

后端 未结 15 1788
挽巷
挽巷 2020-11-28 12:11

This is a really simple question, and it\'s probably a setting somewhere I don\'t know about, but Google is being particularly unhelpful for this question, giving results ab

相关标签:
15条回答
  • 2020-11-28 12:50

    SOLUTION: @Before building your component (using mvn clean install). Build the entire project once and build your component again

    WHY SO :
    I get this error many times. Most of the times I will try to build my component alone (As I have not made changes elsewhere).

    Right, But that extra jar which has been downloaded recently might have affected by changes done by a third party(inside their component). Making a full mvn clean install on entire project saved me many times

    0 讨论(0)
  • 2020-11-28 12:56

    In my case the problem was in a child jar which was not rebuilt since I have added a new class, pom.xml of that child jar was not related to my failed pom.xml as child-to-parent relation (using <parent> tag). So I rebuilt the child jar after which the error had gone.

    0 讨论(0)
  • 2020-11-28 12:57

    This is not a function of Maven; it's a function of the compiler. Look closely; the information you're looking for is most likely in the following line.

    0 讨论(0)
  • 2020-11-28 13:01

    update to 3.1 :

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>
    
    0 讨论(0)
  • 2020-11-28 13:04

    In my case, I was using a dependency scoped as <scope>test</scope>. This made the class available at development time but, by at compile time, I got this message.

    Turn the class scope for <scope>provided</scope> solved the problem.

    0 讨论(0)
  • 2020-11-28 13:04

    Generally, this error will appear when your compile code's version is different from your written code's. For example, write code that rely on xxx-1.0.0.jar that one class has method A, but the method changed to B in xxx-1.1.0.jar. If you compile code with xxx-1.1.0.jar, you will see the error.

    0 讨论(0)
提交回复
热议问题