2017-08-28 48 views
0

我导入我的代码一些外部jar文件.....现在我想我所有的代码导出到一个.jar文件为图书馆和其他项目出口jar文件

使用新项目我应该再次导入该jar文件吗? 如何只导出一个jar文件? 这项工作是否正确?

package dactivemq; 
import javax.jms.Connection; 
import javax.jms.ConnectionFactory; 
import javax.jms.Destination; 
import javax.jms.JMSException; 
import javax.jms.Message; 
import javax.jms.MessageProducer; 
import javax.jms.Session; 
import javax.jms.TextMessage; 
import org.apache.activemq.ActiveMQConnection; 
import org.apache.activemq.ActiveMQConnectionFactory; 
public class Producer {.... 
..... 
+3

您正在使用什么构建工具和/或IDE? –

+0

我使用eclipse只是 –

回答

0

为什么不使用构建工具使这更容易?您可以将其设置为maven项目并使用maven assembly插件创建一个jar-with-dependencies。 Maven的组装插件

用法 - https://maven.apache.org/plugins/maven-assembly-plugin/usage.html

+0

非常感谢你...只是我不知道这个工作是正确的......我的意思是将所有罐子结合在一起生产 –

+0

没问题..如果你想要一个独立的罐子,将不得不与一个与它打包在一起的所有依赖关系的超级jar。 –

0

我建议使用Maven解决依赖关系。要创建一个满足您所需要的单个Jar,我使用如下配置的maven-assembly-plugin:

<plugin> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>single</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <descriptorRefs> 
      <descriptorRef>jar-with-dependencies</descriptorRef> 
     </descriptorRefs> 
     <archive> 
      <manifest> 
       <mainClass>it.xxx.Launcher</mainClass> 
       <addDefaultImplementationEntries>true</addDefaultImplementationEntries> 
       <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> 
      </manifest> 
     </archive> 
    </configuration> 
</plugin>