1. 描述
    使用Maven打包时,总是会出现警告,原因是我引用了本地lib包导致。

D:\workspace\f>mvn package
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.hgc:f2_maven:war:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for org.jbarcode:jbarcode-0.2.8:jar should not point at files within the project di
rectory, ${basedir}/web/WEB-INF/lib/jbarcode-0.2.8.jar will be unresolvable by dependent projects @ line 886, column 16
[WARNING] 'dependencies.dependency.systemPath' for com.hgc.provisioning:ProvisioningClient:jar should not point at files within th
e project directory, ${basedir}/web/WEB-INF/lib/ProvisioningClient.jar will be unresolvable by dependent projects @ line 893, colu
mn 16
[WARNING] 'dependencies.dependency.systemPath' for org.objectweb.rmijdbc:RmiJdbc:jar should not point at files within the project
directory, ${basedir}/web/WEB-INF/lib/RmiJdbc.jar will be unresolvable by dependent projects @ line 900, column 16
[WARNING] 'dependencies.dependency.systemPath' for com.lowagie:itextasian:jar should not point at files within the project directo
ry, ${basedir}/${lib.dir}/itextasian-1.0.jar will be unresolvable by dependent projects @ line 907, column 16
[WARNING]
  1. 分析
    systemPath被设计用来讲一些系统库包含进来,它们往往具有固定的路径。当在自己的project中使用这个特性但是指定相对路径如${basedir}/src/lib之类的,就会提示这个。通过网络搜索,发现解决的方案还是有的。

  2. 解决方法
    方式一、将basedir修改为pom.basedir
    推荐使用方式一,简单方便代码不多。

<dependency>
            <groupId>org.jbarcode</groupId>
            <artifactId>jbarcode-0.2.8</artifactId>
            <version>0.2.8</version>
            <scope>system</scope>
            <systemPath>${pom.basedir}/web/WEB-INF/lib/jbarcode-0.2.8.jar</systemPath>
        </dependency>

方式二、安装到仓库中

如下所示:

    <dependency>
            <groupId>org.jbarcode</groupId>
            <artifactId>jbarcode</artifactId>
            <version>0.2.8</version>
        </dependency>

        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
                <executions>
                    <execution>
                        <id>install-external</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/web/WEB-INF/lib/jbarcode-0.2.8.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>org.jbarcode</groupId>
                            <artifactId>jbarcode</artifactId>
                            <version>0.2.8</version>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
 
 转自:https://www.jianshu.com/p/6c69e6b1b4f4