将依赖打入jar包,由于maven管理了所有的依赖,所以将项目的代码和依赖打成一个包对它来说是顺理成章的功能。maven的这个功能之前就用过,但这次使用时忘了细节,只记得用maven的assembly插件,但assembly插件功能强大,可以打zip、war各种包,所以一下子找不到如何将依赖打入jar包了。浪费了一点时间,所以一定要记录一下。
在pom.xml中加入如下配置即可,关键是configuration-descriptorRefs-descriptorRef,这个就表示要将依赖打入jar包。
Xml代码
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
手动安装Maven依赖包
例如要安装这样一个依赖到maven本地仓库:
1.将此依赖添加到项目的pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>3.0</version>
</dependency>
2.在命令行中执行install命令
mvn install:install-file -Dfile=sqljdbc4-3.0.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=3.0 -Dpackaging=jar
3.将sqljdbc4-3.0.jar拷贝到此依赖安装目录
将sqljdbc4-3.0.jar拷贝到X:\Documents and Settings\%USER%\.m2\repository\com\microsoft\sqlserver\sqljdbc4\3.0 中即可.





















大小: 8KB
大小: 89.5M
终端仿真器 SecureCRTv7.1.1.264 最新版
串口调试小助手1.3 免费版
WinHex 十六进制编辑器v20.2 SR-5 绿色中文注册版
小旋风ASP服务器安装版
16进制转换工具V1.0 中文绿色版
Adobe AIRV33.1.1.932 官方最新版
github离线安装包64位版V2.9.11官方最新版(github desktop)
MSDN Library Visual Studio 6.0(VC、VB、VF、VJ)中文版win32开发人员必备
版本控制软件(SourceTree)v3.4.6 官方最新版
Memory Analyzer (MAT)V1.01 免费绿色版
Delphi Distillerv1.85绿色版
IBM内存检测工具(IBM Thread and Monitor Dump Analyzer for Java)V4.3.3 绿色版
.NETv3.0 可再发行组件包
一键安装JSP环境安装版
slave4j(基于eclipse插件的java代码生成器)V1.0.0 正式版
Auto DebugProfessional 5.6.5.18 中文绿色版
Understand For C++V1.4.319英文安装版