Import the local jar to the local repository

Method 1. Install the maven environment and specify the environment variables Open the cmd command line
in the jar package directory and execute the following command to

install the specified file to the local warehouse command: mvn install:install-file
-DgroupId=<groupId> : Set the package of the project code Name (generally used organization name)
-DartifactId=<artifactId> : Set the project name or module name
-Dversion=1.0.0 : Version number
-Dpackaging=jar : What type of file (jar package)
-Dfile=<myfile.jar> : Specify the jar file path and file name (only the file name is required in the same directory)
Installation command example:
mvn install:install-file -DgroupId=com.baidu -DartifactId=ueditor -Dversion=1.0.0 -Dpackaging=jar -Dfile=ueditor -1.1.2.jar

Method 2:
Method 1: Put the package to be imported in a directory such as lib directory, modify the pom file, add dependencies and set the scope to system


<dependencies> 
    <dependency> 
        <groupId>com.fbcds </groupId> 
        <artifactId>fbcds</artifactId> 
        <version>1.0</version> 
        <scope>system</scope> 
        <systemPath>${project.basedir}/lib/fbcds.jar</systemPath> 
    </dependency> 
</dependencies> 

After the above settings are completed, run mvn The package command was executed successfully. But the typed package does not contain the lib directory and the referenced package fbcds.jar, that is, the typed package is not an executable jar. So if you are developing individually, you can use this method. If you are developing in a team, please use method 1.



Method 3:
1. Create the following folders in your root directory folder
such as D:\maven_repository\ Create the ImApi folder --> then create the ImApi folder --> then create the 1.0 folder
and finally put the ImApi.jar in 1.0
folder Change ImApi.jar to ImApi-1.0.jar, and create the file ImApi-1.0.pom.

2. Then write the following in ImApi-1.0.pom

<project>  
  <modelVersion>1.0.0</modelVersion>  
  <groupId>ImApi</groupId>  
  <artifactId>ImApi</artifactId>  



3. Just import it in the pom.xml dependency of your project

       <dependency>
            <groupId>ImApi</groupId>
            <artifactId>ImApi</artifactId>
            <version>1.0</version>
        </dependency>

4. After saving pom.xml will report an error, right-click the project - Maven - Update Project
and check the force update of snapshots/releases option.



${basedir} Project root directory  
${version} represents the project version; 
${project.basedir} is the same as ${basedir}; 
${project.version} represents the project version, same as ${version}; 
${project.build. directory} build directory, the default is target 
${project.build.sourceEncoding} indicates the encoding format of the main source code; 
${project.build.sourceDirectory} indicates the main source code path; 
${project.build.finalName} indicates the output file name; 
${project.build. 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326313184&siteId=291194637