Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven compile successful, but install failed

I am using maven 3.2.2 and jdk-1.7.0_60. I am executing mvn compile for a particular project, the compilation succeeds. But when I run mvn clean install on the same component, I get the following error-

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/projects/myProject/src/mainTest.java:[105,56] cannot find symbol
  symbol:   method getIdFromName(java.lang.String)
  location: class java.lang.Object

What could be the reason behind this? Doesn't mvn compile actually compile everything? As far as I know, the only difference between mvn compile and mvn clean install is that the latter command copies the required jar.

like image 719
AlwaysALearner Avatar asked Oct 23 '25 18:10

AlwaysALearner


2 Answers

If you take a look at the Maven Build Lifecycle, you will notice that test-compile phase goes after compile, but before install.

Since the file which fails to compile is mainTest.java, looks like this is your problem:

Doesn't mvn compile actually compile everything?

No, it doesn't compile test sources.

like image 87
izstas Avatar answered Oct 26 '25 07:10

izstas


I was facing same, this started when I added unit test cases, what worked for me is, first run

mvn clean install -DskipTests=true

Then again run

mvn clean install
like image 41
Pratik Goenka Avatar answered Oct 26 '25 07:10

Pratik Goenka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!