简体   繁体   English

在Maven Eclipse中构建多个可运行的Jar

[英]Building multiple runnable jars in maven eclipse

I have a java project in eclipse that contains multiple classes.I recently converted the project to a maven project and i am new to maven.I set the dependencies in the pom.xml and everything is fine.However , i want to make a runnable jar file from each class keeping in mind the jar files/libraries i am using in my project should be used/extracted by the obtained jar. 我在eclipse中有一个包含多个类的java项目。我最近将该项目转换为maven项目,而我是maven的新手。我在pom.xml中设置了依赖项,一切都很好。但是,我想使它可运行每个类的jar文件都应记住,我在项目中使用的jar文件/库应该由获得的jar使用/提取。

How can i do it in maven?I was able to do it using the export before now its not working. 我怎么能在Maven中做到呢?

Thanks for your help 谢谢你的帮助

一种方法是为每个可运行的JAR文件制作一个单独的POM文件(并因此制作Eclipse项目)。

If you want maven to build your project into multiple jars it's probably a good idea to step back and re-asses how you project is structured and why you chose to use maven in the first place. 如果您希望Maven将项目构建到多个jar中,则最好退一步并重新评估项目的结构以及为什么首先选择使用Maven。 There are actually ways to do this but they're all horrible. 实际上,有很多方法可以做到,但是它们都是可怕的。 You don't want maven to build multiple jars and you certainly don't want to make a runnable jar file for each class. 您不希望Maven构建多个jar,当然也不想为每个类创建可运行的jar文件。 You potentially need to split your project into multiple smaller ones. 您可能需要将您的项目分成多个较小的项目。

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

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