4

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?

qiGuar
  • 1,726
  • 1
  • 18
  • 34

4 Answers4

8

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.

Mohsen Heydari
  • 7,256
  • 4
  • 31
  • 46
Farzad Fallah
  • 591
  • 4
  • 9
4

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.

Mike Braun
  • 3,729
  • 17
  • 15
maksimov
  • 5,792
  • 1
  • 30
  • 38
  • 1
    You can use this website (http://www.findjar.com) to localize JARs by class names. Then you can find the maven dependence in http://search.maven.org/ – polypiel Sep 23 '13 at 13:52
  • You can also use search.maven.org or jarvana.com or mvnrepository.com. – carlspring Sep 23 '13 at 14:34
0

You need to check the NoClassDefFoundError in your output logs and add dependencies accordingly.

The best resource to search for missing dependencies is Maven Central Repository

To get a detailed debug log of your build, use -X in the command line.

You can check The dependency tree of your project by following command - mvn dependency:tree. This will only list the information about the deoendencies listed in your pom.xml More on it here

Arpit
  • 6,212
  • 8
  • 38
  • 69
0

should be able to do it with :

maven dependency resolve

enter image description here

Hard Worker
  • 995
  • 11
  • 33