解决Maven使用<systemPath>标签的warning

本文介绍如何使用maven-install-plugin解决Maven项目中&lt;systemPath&gt;标签导致的警告。通过配置插件,将外部依赖安装到本地仓库,避免打包时出现警告。插件的最新版本可在官网查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当maven项目中使用<systemPath>标签时,打包项目时会报警告,具体如下所示:

为了解决这个warning,使用如下maven插件:

<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}/lib/mylib-core-0.0.1.jar</file>
                <repositoryLayout>default</repositoryLayout>
                <groupId>com.mylib</groupId>
                <artifactId>mylib-core</artifactId>
                <version>0.0.1</version>
                <packaging>jar</packaging>
                <generatePom>true</generatePom>
            </configuration>
            <goals>
                <goal>install-file</goal>
            </goals>
        </execution>
    </executions>
</plugin>

当打包maven项目时,首先运行 mvn clean 命令,再运行 mvn package 命令,即可生成jar包。

其中,插件的最新版本请到下面的网站查询:

maven-install-plugin:https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-install-plugin

参考文献:https://stackoverflow.com/questions/10935135/maven-and-adding-jars-to-system-scope

> sudo mvn clean package [sudo] password for shl: [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com.xkhy.tafang:tafang-server:jar:1.0-SNAPSHOT [WARNING] 'dependencies.dependency.systemPath' for com.cca:cca-agent:jar should not point at files within the project directory, ${project.basedir}/lib/cca-agent-0.0.2.jar will be unresolvable by dependent projects @ line 160, column 16 [WARNING] 'dependencies.dependency.systemPath' for com.cca:cca-core:jar should not point at files within the project directory, ${project.basedir}/lib/cca-core-0.0.39.jar will be unresolvable by dependent projects @ line 167, column 25 [WARNING] 'dependencies.dependency.systemPath' for com.cdi-api:cdi-api:jar should not point at files within the project directory, ${project.basedir}/lib/cdi-api-1.0.jar will be unresolvable by dependent projects @ line 174, column 25 [WARNING] [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] [INFO] [INFO] -------------------< com.xkhy.tafang:tafang-server >-------------------- [INFO] Building tafang-server 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [WARNING] The POM for com.xkhy.tafang:tafang-common:jar:0.0.12 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details / 解读一下警告。
05-22
[WARNING] [WARNING] Some problems were encountered while building the effective model for com.hw:asset:jar:1.0.0 [WARNING] 'dependencies.dependency.systemPath' for com.huawei.gauss:com.huawei.gauss.jdbc.ZenithDriver:jar should not point at files within the project directory, ${project.basedir}/lib/gaussdbv3.jdbc-V300R001C00CP2075.jar will be unresolvable by dependent projects @ line 45, column 25 [WARNING] [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] [INFO] [INFO] ----------------------------< com.hw:asset >---------------------------- [INFO] Building asset 1.0.0 [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- resources:3.2.0:resources (default-resources) @ asset --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Using 'UTF-8' encoding to copy filtered properties files. [INFO] Copying 3 resources [INFO] Copying 0 resource [INFO] [INFO] --- compiler:3.10.1:compile (default-compile) @ asset --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.071 s [INFO] Finished at: 2025-07-16T10:46:59+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project asset: Resolution of annotationProcessorPath dependencies failed: For artifact {org.projectlombok:lombok:null:jar}: The version cannot be empty. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
最新发布
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值