简体   繁体   English

为项目获取所有必需的Jar

[英]Getting all required Jar for project

I have a piece of code in my java project where I am getting all jar from classpath using- 我在我的java项目中有一段代码,我从classpath获取所有jar使用 -

System.getProperty("java.class.path", "."); System.getProperty(“java.class.path”,“。”);

When I am executing this on my local windows machine it's giving me the bunch of jar file. 当我在我的本地Windows机器上执行它时,它给了我一堆jar文件。 But when same code I tried to execute on Linux Box using command line, it's giving only one jar as following- 但是当我尝试使用命令行在Linux Box上执行相同的代码时,它只给出一个jar如下 -

/usr/local/apache-maven-3.5.3/boot/plexus-classworlds-2.5.2.jar /usr/local/apache-maven-3.5.3/boot/plexus-classworlds-2.5.2.jar

Any idea/suggestion will be highly appriciated. 任何想法/建议都会受到高度关注。

To copy all the dependencies you've defined in pom.xml , run 要复制您在pom.xml定义的所有依赖项,请运行

mvn dependency:copy-dependencies

in the same directory and check target/dependency . 在同一目录中并检查target/dependency

There are many other approaches like using the maven-assembly-plugin or building a fat JAR with maven-shade-plugin . 还有许多其他方法,比如使用maven-assembly-plugin或使用maven-shade-plugin构建一个胖JAR。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM