Maven 常用命令

Siona

Maven 常用命令

1. mvn install:install-file

Maven 安装本地 jar 到本地仓库(.m2/repository)

<!-- pom.xml -->
<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>words</artifactId>
        <version>20.12</version>
    </dependency>
</dependencies>
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version>

# 举例
mvn install:install-file \
-Dfile=aspose-words-20.12-jdk17-crack.jar \
-DgroupId=com.aspose \
-DartifactId=words \
-Dversion=20.12 \
-Dpackaging=jar

遇到的问题:

问题一

# 找不到 mvn 命令
command not found: mvn

解决方法:

source ~/.bash_profile

参考文章open in new window

问题二

# 执行 mvn install:install-file 命令报错
The artifact information is incomplete: 'groupId', 'artifactId', 'version' and 'packaging' are required.

原因:pom.xml 与 mvn install:install-file 的参数不匹配。

扩展

shell 参数换行

Linux 参数太长,一般可取续行符 \ 进行参数换行或续行。反斜杠 \ 后面紧跟回车,表示下一行是当前行的续行。

python target_attack.py \
  --input_dir="${INPUT_DIR}" \
  --output_dir="${OUTPUT_DIR}" \

【注意】 \ 后面紧接着是 enter换行符,即使用 \回车 的方式,不能有空格之类的任何符号,否则会造成解析错误,导致后面的参数赋值不成功。

2.

Last Updated 3/2/2024, 4:00:59 PM