Skip to main content
Active reading [<https://en.wikipedia.org/wiki/Apache_Maven> <https://english.stackexchange.com/questions/4645/is-it-ever-correct-to-have-a-space-before-a-question-or-exclamation#comment206109_4645>]. Added some context.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

One way to get this error in Eclipse Eclipse:

  1. Define a class A in src/test/java.
  2. Define another class B in src/main/java that uses class A.

Result  : Eclipse will compile the code, but mavenMaven will give "Cannot find symbol".

Underlying cause  : Eclipse is using a combined build path for the main and test trees. Unfortunately, it does not support using different build paths for different parts of an Eclipse project, which is what Maven requires.

Solution  :

  1. Don't define your dependencies that way; i.e., don't make this mistake.
  2. Regularly build your codebase using Maven so that you pick up this mistake early. One way to do that is to use a CICI server.

One way to get this error in Eclipse :

  1. Define a class A in src/test/java.
  2. Define another class B in src/main/java that uses class A.

Result  : Eclipse will compile the code, but maven will give "Cannot find symbol".

Underlying cause  : Eclipse is using a combined build path for the main and test trees. Unfortunately, it does not support using different build paths for different parts of an Eclipse project, which is what Maven requires.

Solution  :

  1. Don't define your dependencies that way; i.e. don't make this mistake.
  2. Regularly build your codebase using Maven so that you pick up this mistake early. One way to do that is to use a CI server.

One way to get this error in Eclipse:

  1. Define a class A in src/test/java.
  2. Define another class B in src/main/java that uses class A.

Result: Eclipse will compile the code, but Maven will give "Cannot find symbol".

Underlying cause: Eclipse is using a combined build path for the main and test trees. Unfortunately, it does not support using different build paths for different parts of an Eclipse project, which is what Maven requires.

Solution:

  1. Don't define your dependencies that way; i.e., don't make this mistake.
  2. Regularly build your codebase using Maven so that you pick up this mistake early. One way to do that is to use a CI server.
added 529 characters in body
Source Link
Stephen C
  • 723.4k
  • 95
  • 849
  • 1.3k

One way to haveget this error in Eclipse :

  1. define yourDefine a class A in src/test/java.
  2. use itDefine another class B in src/main/java that uses class A.

Result : eclipse compilesEclipse will compile the code, but maven will give "Cannot find symbol".

Underlying cause : Eclipse is using a combined build path for the main and test trees. Unfortunately, it does not support using different build paths for different parts of an Eclipse project, which is what Maven requires.

Solution :

  1. Don't define your dependencies that way; i.e. don't make this mistake.
  2. Regularly build your codebase using Maven so that you pick up this mistake early. One way to do that is to use a CI server.

One way to have this error in Eclipse :

  1. define your class in src/test/java
  2. use it in src/main/java

Result : eclipse compiles, maven does not.

One way to get this error in Eclipse :

  1. Define a class A in src/test/java.
  2. Define another class B in src/main/java that uses class A.

Result : Eclipse will compile the code, but maven will give "Cannot find symbol".

Underlying cause : Eclipse is using a combined build path for the main and test trees. Unfortunately, it does not support using different build paths for different parts of an Eclipse project, which is what Maven requires.

Solution :

  1. Don't define your dependencies that way; i.e. don't make this mistake.
  2. Regularly build your codebase using Maven so that you pick up this mistake early. One way to do that is to use a CI server.
Source Link
Joel Costigliola
  • 7.3k
  • 1
  • 33
  • 38

One way to have this error in Eclipse :

  1. define your class in src/test/java
  2. use it in src/main/java

Result : eclipse compiles, maven does not.