eclipse打maven的jar包连依赖jar一起打包方法
maven
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
项目地址:https://gitcode.com/gh_mirrors/ma/maven
·
方法就是使用maven插件,我这里试验了2种插件
方法1.
第一步:在pom.xml文件中添加,其中标红的部分,我在实际应用中是去掉的,因为我这个jar单纯是工具类,没有主函数,如果有的话,红色部分改成自己的启动类应该就行了
第二步:右键pom.xml--->run config里运行命令输入assembly:assembly
直接运行后会打出2个jar包,名字分别是下边这2个,名字段的是本身的jar,名字长的是连依赖一起打的jar
box-dbc-util-0.0.1-SNAPSHOT.jar
box-dbc-util-0.0.1-SNAPSHOT-jar-with-dependencies.jar
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<span style="color:#FF0000;"> <archive>
<manifest>
<mainClass>com.allen.capturewebdata.Main</mainClass>
</manifest>
</archive> </span>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
方法2:
第一步:这个方法是我一个同事用的,使用的是另外一种插件,在pom.xml里添加如下配置
第二步:直接右键pom.xml 点击maven install就可以了
也是打出2个jar,原名的那个短的是连依赖一起打出来的jar,长的那个是原始,只有自己相关类的jar
box-dbc-util-0.0.1-SNAPSHOT.jar
original-box-dbc-util-0.0.1-SNAPSHOT.jar
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:2 个月前 )
0d886c5f
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 5.0.0 to 5.1.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/dded0888837ed1f317902acf8a20df0ad188d165...f2beeb24e141e01a676f977032f5a29d81c9e27e)
---
updated-dependencies:
- dependency-name: actions/setup-java
dependency-version: 5.1.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2 天前
19c7fa2d
Bumps [org.codehaus.plexus:plexus-testing](https://github.com/codehaus-plexus/plexus-testing) from 2.0.1 to 2.0.2.
- [Release notes](https://github.com/codehaus-plexus/plexus-testing/releases)
- [Commits](https://github.com/codehaus-plexus/plexus-testing/compare/plexus-testing-2.0.1...plexus-testing-2.0.2)
---
updated-dependencies:
- dependency-name: org.codehaus.plexus:plexus-testing
dependency-version: 2.0.2
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 4 天前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)