Package Jar as Maven Package jar as maven Package java project as maven Package Java project as Maven

I wrote a general SDK Jar package by myself, but the current projects are all Maven projects, so I need to package the Jar in Maven format and output it to the local Maven warehouse, which can be referenced in the project

Check if Maven is installed

Open CMd and enter mvn -vto query the version number

insert image description here

Packaging Jar

I have a sample Jar file here calledk3cloud-webapi-sdk8.0.5.jar

Then you can execute the following command

mvn install:install-file -Dfile=k3cloud-webapi-sdk8.0.5.jar  -DgroupId=com.liyang -DartifactId=k3cloud-webapi-sdk -Dversion=8.0.5 -Dpackaging=jar

打包成功输出

BUILD SUCCESSSuccessful

The output file can be checked in the Maven local warehouse path to see if it exists
insert image description here

Command parameter analysis

Take a Maven project POM.XML file for comparison

        <dependency>
            <groupId>com.liyang</groupId>
            <artifactId>k3cloud-webapi-sdk</artifactId>
            <version>8.0.5</version>
        </dependency>

insert image description here

-Dfile=要打包的文件名称

-DgroupId=对应POM.XML文件的 groupId 标签内容

-DartifactId=对应POM.XML文件的 artifactId 标签内容

-Dversion=对应POM.XML文件的 version 标签内容

Guess you like

Origin blog.csdn.net/qq_40739917/article/details/131322893