mavean项目中,对非mavean管理的第三方jar包处理

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37222746/article/details/85270098

通常情况下用mavean打包的时候,对非mavean管理的第三方jar包只需要在pom.xml 里加入如下配置就行了。

<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
      <compilerArguments>        
         <extdirs>${basedir}/dlls</extdirs>
      </compilerArguments>
   </configuration>
</plugin>

但有的时候这样行不通。需要把jar包安装到mavean本地数据库里。然后由mavean来管理它们。

将本地的jar文件安装到本地repository中,具体步骤如下:
1、准备好本地的jar文件
2、使用如下命令安装jar文件
      mvn install:install-file -Dfile=abc.jar 
     -DgroupId=com.mycompany.myproduct -DartifactId=abc 
     -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true 
    其中,-Dfile制定jar文件的位置。执行完该命令后,会在本地repository(通常是$HOME/.m2目录)中出现一个目录(com),在其下会有一个abc-1.0.jar的文件和一个自动产生的pom文件。
3、安装完之后,在另一个应用程序中使用它的时候,只要在pom文件中指定相应的dependency就可以,如:
     <dependencies>
          <dependency>
          <groupId>com.mycompany.myproduct</groupId>
          <artifactId>abc</artifactId>
          <version>1.0</version>
       </dependency>
    </dependencies>

上面那段plugin配置就不需要了。

 

进入文件夹D:\svn\Bigdata\IOT\iot-village-consumer\libs

mvn install:install-file -Dfile=Digests.jar  -DgroupId=com.mycompany.myproduct -DartifactId=Digests -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true 

猜你喜欢

转载自blog.csdn.net/m0_37222746/article/details/85270098
今日推荐