念念不忘
必有回响

Maven提示dependencies.dependency.systemPath的警告信息

最近对项目进行重构,期间解决了依赖冲突,将不必要的模块剔除,升级依赖版本等,做完这一切后整个项目目前运行还算正常,不过注意到使用Maven打包的时候经常会出现如下告警:

[WARNING] Some problems were encountered while building the effective model for com.raysdata:traffic-search-server:war:1.3.0-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.cloudera.impala.jdbc:hive_metastore:jar should not point at files within the project directory, ${project.basedir}/libs/hive_metastore.jar will be unresolvable by dependent projects @ line 26, column 25
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 

尽管这个告警对项目的打包、运行都不影响,但0 errors 0 warns应该是每个有洁癖的程序员都喜欢的吧,那就解决这个告警吧。
根据日志提示,应该是pom文件中的本地依赖${project.basedir}/libs/hive_metastore.jar之类的Impala依赖造成的,面向Google编程了一会了找到了解决方案,先看看原来的pom.xml文件中的定义:

<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>hive_metastore</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/libs/hive_metastore.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>hive_service</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/libs/hive_service.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>ImpalaJDBC41</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/libs/ImpalaJDBC41.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>ql</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/libs/ql.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>TCLIServiceClient</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/libs/TCLIServiceClient.jar</systemPath>
</dependency>

1根据警告信息提示,都是这些依赖出的问题,不过或许旧版本这么写完全没问题,但是现在大家都用的最新版的maven,所以这个错误应该是新版本带来的问题,将${project.basedir}修改为${pom.basedir}即可解决这个警告信息

<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>hive_metastore</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/hive_metastore.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>hive_service</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/hive_service.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>ImpalaJDBC41</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/ImpalaJDBC41.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>ql</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/ql.jar</systemPath>
</dependency>
<dependency>
    <groupId>com.cloudera.impala.jdbc</groupId>
    <artifactId>TCLIServiceClient</artifactId>
    <version>${impala.jdbc.version}</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/libs/TCLIServiceClient.jar</systemPath>
</dependency>

最终结果:

0 error(s), 0 warning(s)

maven

赞(0) 打赏
未经允许不得转载:码农志 » Maven提示dependencies.dependency.systemPath的警告信息

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏