在日常开发过程中,有些第三方jar包在maven仓库中是找不到的,比如:在与另外一个系统对接的过程中,需要用到对接方系统提供的jar包。 那遇到这样的情况怎么办呢?
一,查找java中jar包的maven仓库地址
1.http://mvnrepository.com/ (推荐)
2.http://search.maven.org/
3.http://repository.sonatype.org/content/groups/public/
4.http://www.sonatype.org/nexus/
5.http://repo1.maven.org/maven2
以 spring-context-support-3.1.0.RELEASE.jar 为例,在 @3图中已经给出这个 jar 包的 groupId,artifactId,version信息,
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
Maven 安装 JAR 包的命令是:(window:cmd)
mvn install:install-file -Dfile=jar包的位置 -DgroupId=上面的groupId -DartifactId=上面的artifactId -Dversion=上面的version -Dpackaging=jar
如:【生成alkacon-simapi-1.0.0.jar】
mvn install:install-file -Dfile=D:\Data\alkacon-simapi-1.0.0.jar -DgroupId=com.alkacon -DartifactId=alkacon-simapi -Dversion=1.0.0 -Dpackaging=jar
回车,显示安装成功:
引用:
<dependency>
<groupId>com.alkacon</groupId>
<artifactId>alkacon-simapi</artifactId>
<version>1.0.0</version>
</dependency>