List of dependency jar files in Maven

后端 未结 9 2250
我在风中等你
我在风中等你 2020-12-04 09:50

Using Maven 2, is there a way I can list out the jar dependencies as just the file names?

mvn dependency:build-classpath 

can list the jar

9条回答
  •  Happy的楠姐
    2020-12-04 10:05

    Here's the command you're asking for

    $ mvn dependency:tree
    

    For large projects it can output a lot of text. I assume that you want to check that dependency tree contains a certain dependency, so you don't need a full list.

    Here's how you can filter output on Windows:

    $ mvn dependency:tree | findstr javax.persistence
    

    And here's how you can do it on Linux:

    $ mvn dependency:tree | grep javax.persistence
    

    Maven way to filter the dependency tree (works in Windows cmd, MacOS and Linux shell):

    $ mvn dependency:tree -Dincludes=javax.persistence:*
    

    Maven way (Windows PowerShell):

    $ mvn dependency:tree '-Dincludes=javax.persistence:*'
    

提交回复
热议问题