zoukankan      html  css  js  c++  java
  • 既使用maven又使用本地Jar包

    maven 使用本地包 lib jar包 依赖一个lib目录

    解决方法:

    1. 把本地的lib加入maven编译时的依赖路径

         如下配置:

         <plugin> 
                  <artifactId>maven-compiler-plugin</artifactId> 
                  <configuration> 
                      <source>1.6</source> 
                      <target>1.6</target> 
                      <encoding>UTF-8</encoding> 
                      <compilerArguments> 
                       <extdirs>lib/</extdirs> 
                     </compilerArguments> 
                  </configuration> 
                </plugin>
    

      

    2. 本地system 配置

       这种的不好处是,只能加入某个jar包而不是某个目录

    <dependency>
        <groupId>org.swinglabs</groupId>
        <artifactId>swingx</artifactId>
        <version>0.9.2</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/lib/swingx-0.9.3.jar</systemPath>
    </dependency>
    

      

    3. 把jar包安装入本地仓库

      - 先安装jar包到本地仓库

      - 引用安装的jar包

          注意: 正规maven的方法,要求jar包中有合法的 artifactId信息

    <repository>
        <id>repo</id>
        <releases>
            <enabled>true</enabled>
            <checksumPolicy>ignore</checksumPolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <url>file://${project.basedir}/repo</url>
    </repository>

    4. 使用install  插件  (推荐使用)

         配置如下:

    <plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-install-plugin</artifactId>
    				<executions>
    					<execution>
    						<id>install-external</id>
    						<phase>clean</phase>
    						<configuration>
    							<file>${basedir}/lib/app-0.0.1.jar</file>
    							<repositoryLayout>default</repositoryLayout>
    							<groupId>com.dalong.locallib</groupId>
    							<artifactId>appbanner</artifactId>
    							<version>0.0.1</version>
    							<packaging>jar</packaging>
    							<generatePom>true</generatePom>
    						</configuration>
    						<goals>
    							<goal>install-file</goal>
    						</goals>
    					</execution>
    				</executions>
    			</plugin>
    

      

         

    5. 使用命令

       

    mvn install:install-file  -Dfile=D:/jar/xxx.jar  -DgroupId=xxx.xxx  -DartifactId=xxx -Dversion=x.x -Dpackaging=jar
    

      

         

  • 相关阅读:
    深入Apache NiFi 之源码学习
    Apache NiFi 核心概念和关键特性
    运营商手机视频流量包业务日志ETL及统计分析
    HDP Hive性能调优
    redis 实现登陆次数限制
    Hadoop和Spark的Shuffer过程对比解析
    Scala-基础知识
    Python基础知识问答
    Python基础知识+计算器练习
    Sqoop架构原理及常用命令参数
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/5959456.html
Copyright © 2011-2022 走看看