Maven compile gives: Cannot find symbol - For a class sitting in the same app

后端 未结 3 1134
耶瑟儿~
耶瑟儿~ 2021-02-20 14:13

It\'s a while since I met such puzzling issue. I\'m having a class that references another one sitting in another package in the same application, that is, NOT in another jar ar

3条回答
  •  爱一瞬间的悲伤
    2021-02-20 14:35

    Problem Description:

    I had similar problem with my project with below structure.

    project
    -pom.xml
    
    -common-module  
    --src, pom.xml, etc
    
    -web-module  
    --src, pom.xml, etc (but dependent on 'common')
    

    mvn install would run fine for common-module but gives compilation error for web-module code that uses java class from common-module (cannot find symbol). I was using JDK 8 + Maven 3.2.5, but in pom compiler lever is set to 7.

    MY Solution:

    I have installed JDK 7 and Maven 3.1.1 and did a mvn install. Bingo..! Every with worked fine & Build Successful.

    I couldn't find a solution for my problem any where, so though of posting my fix here as it is related. (may be it could help some one)

提交回复
热议问题