既使用maven又使用本地Jar包

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

解决方法:

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

     如下配置:

1
2
3
4
5
6
7
8
9
10
11
<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包而不是某个目录

1
2
3
4
5
6
7
<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信息

1
2
3
4
5
6
7
8
9
10
11
<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  插件  (推荐使用)

     配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<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. 使用命令

   

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

  http://www.cnblogs.com/rongfengliang/p/5959456.html

猜你喜欢

转载自m635674608.iteye.com/blog/2390652