Sunday, September 21, 2014

How to Fix Maven compile Cannot find symbol

Removed
I was compiling a project using Maven  when I got this error:




Compilation failure: Compilation failure:
[ERROR] /C:/test/unittest/TestManager.java:[3,24] package org.junit does not exist
[ERROR] /C:/test//unittest/TestManager.java:[3,1] static import only from classes and interfaces
[ERROR] /C:/test/unittest/TestManager.java:[138,10] cannot find symbol
[ERROR] symbol:   class Test
[ERROR] location: class org.test.unittest.TestManager
[ERROR]  /C:/test/unittest/TestManager.java:[19,17] cannot find symbol
[ERROR] symbol:   method assertFalse(boolean)

My Junit package was thete as I don't have errors in my code. But NO, I wasn't adding it as a Dependency in the pom but as a jar in my Build Path.

So in order to fix the problem, I have removed JUnit form the Build Path and added it as Dependency:


<dependency>
    <groupId>junit</groupId>
    <artifactId>junit-dep</artifactId>
    <version>4.11</version>
</dependency>


That is it ;)

8 comments :

  1. Replies
    1. Thanks for thanking this post

      Delete
    2. This comment has been removed by a blog administrator.

      Delete
    3. This comment has been removed by a blog administrator.

      Delete
    4. This comment has been removed by a blog administrator.

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete

Articles les plus consultés