我正在做一个maven项目。编译和运行我的项目时,一切都很顺利,但每当我创建jar文件时,web/lib /中的外部jar文件都不能复制到jar文件中。为什么会发生?我可以将所有文件插入jar文件吗?将jar库添加到jar文件中
2
A
回答
0
是我找到的解决方案。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<finalName>HelloWorld</finalName>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.gui.launcher.LauncherMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- this is used for inheritance merges -->
<phase>package</phase>
<!-- append to the packaging phase. -->
<goals>
<goal>single</goal>
<!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
2
您可以使用Maven Assembly Plugin的jar-with-dependencies描述符来实现此目的。
1
您需要使用是这样的:
</project>
...
<build>
...
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest> <!-- requires for executable Jar -->
<mainClass>org.my.main.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <!-- final Jar will have this text appended -->
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
....
</plugins>
</build>
</project>
相关问题
- 1. 如何将jar库添加到jar中
- 2. 将库路径添加到jar文件
- 3. 如何将jar文件添加到jar文件中?
- 4. 添加jar文件到C#类库
- 5. 将外部库添加到JAR中?
- 6. 将Jar文件添加到Maven
- 7. 将属性文件添加到jar
- 8. 如何将sourceset添加到jar文件?
- 9. Gradle - 将单个文件添加到JAR
- 10. 将Jar文件添加到WEB-INF/lib
- 11. 将.jar文件添加到React本机
- 12. 将.jar文件添加到类路径
- 13. 将外部文件添加到jar
- 14. 将.dll文件添加到jar
- 15. 如何将jar文件添加到Classpath?
- 16. 添加Jar文件
- 17. Java:将包含的Jar文件添加到Linux中创建的Jar文件中
- 18. 将AndEngine库添加为jar
- 19. 添加图像到jar库
- 20. 将jar添加到eclipse插件中
- 21. 将JAR添加到Eclipse Java库
- 22. Android将jar添加到自定义库
- 23. 将库添加到java,CLASSPATH,jar,linux
- 24. 将jar库添加到Maven项目
- 25. 将Volley和Gson添加到库Jar
- 26. 将外部库.jar添加到Spring引导.jar内部/ lib
- 27. 将HttpClient jar添加到eclipse
- 28. 将jar添加到java webapp
- 29. 将Jsoup Jar添加到MapReduce
- 30. 将sqlite数据库添加到可执行的JAR文件
我已经使用过这个插件。我在我的项目中使用Symmetricds jar文件,但在jar文件中看不到这些jar文件。在web/lib目录中对称jar文件。 – olyanren 2011-02-15 08:33:40