When I ran the command 'mvn clean install' and again 'mvn install', the project was able to build properly but, I wanted a clean reason to understand this weird behaviour i.e I had to run the command 'mvn install' again after 'mvn clean install'.

I then realized that there was some problem with the source folder configurations so , I made the following configuration to the POM :

<sourceDirectory>../src/main/java</sourceDirectory>.

After making this change the command 'mvn clean install' started woring like a charm.

Please note : I am documenting this only for information purpose (As,it does not look like question) though, anyone who has any idea to this strange behaviour may try to improve this post.