Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find which maven dependencies are missing

Tags:

java

maven

I have a web project and a pom.xml file. It has enough dependencies to compile and package but not enough to start the project. In my IDE it's shown that everything is ok, but when a start the application it has errors. When i add external pom.xml from another app, my application launches.

So is there any way i can find out which dependencies are missing and how in future i can determine which dependencies are needed for using this or that?

like image 499
qiGuar Avatar asked Dec 16 '22 06:12

qiGuar


2 Answers

You can use mvn dependency:analyze for determining which dependencies are used and declared or used and undeclared or unused and declared.
For more information refer to: http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html.

Hope this helps.

like image 99
Farzad Fallah Avatar answered Dec 26 '22 11:12

Farzad Fallah


There's no maven command to accomplish this. You need to check which classes are causing NoClassDefFoundError, figure out the dependency (Google) - which JARs they are shipped in, and add them with the runtime scope in your pom.xml.

In web projects specifically you oftentimes compile against servlets or Java EE specification JARs (they would only contain interfaces), but you need actual implementation JARs to be present in runtime. These JARs are typically and presumed to be available in the container you are running in (like Tomcat or JBoss), in this case they would be marked as provided scope in your pom.xml.

like image 25
maksimov Avatar answered Dec 26 '22 12:12

maksimov