命令:
mvn install:install-file
示例:
mvn install:install-file -Dfile=unoil-1.0.jar -DgroupId=com.mycompany -DartifactId=unoil -Dversion=1.0 -Dpackaging=jar
有些小伙伴操作时可能会遇到报错情况The goal you specified requires a project to execute but there is no POM in this directory....,这可能与平台相关,博主在windows也遇到过这种情况,解决方案是给参数加上英文输入法下的双引号
mvn install:install-file "-Dfile=unoil-1.0.jar" "-DgroupId=com.mycompany" "-DartifactId=unoil" "-Dversion=1.0" "-Dpackaging=jar"
注意,等号右侧不要留空格,不然会报错
参数解释:
ArtifactId of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
- Type: java.lang.String
- Required: No
- User Property: artifactId
Classifier type of the artifact to be installed. For example, "sources" or "javadoc". Defaults to none which means this is the project's main artifact.
- Type: java.lang.String
- Since: 2.2
- Required: No
- User Property: classifier
文件路径
The file to be installed in the local repository.
- Type: java.io.File
- Required: Yes
- User Property: file
是否生成pom文件,默认为true
Generate a minimal POM for the artifact if none is supplied via the parameter pomFile. Defaults to true if there is no existing POM in the local repository yet.
- Type: java.lang.Boolean
- Since: 2.1
- Required: No
- User Property: generatePom
GroupId of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
- Type: java.lang.String
- Required: No
- User Property: groupId
The bundled API docs for the artifact.
- Type: java.io.File
- Since: 2.3
- Required: No
- User Property: javadoc
The path for a specific local repository directory. If not specified the local repository path configured in the Maven settings will be used.
- Type: java.io.File
- Since: 2.2
- Required: No
- User Property: localRepositoryPath
打包方式
Packaging type of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
- Type: java.lang.String
- Required: No
- User Property: packaging
jar包中pom文件的路径
Location of an existing POM file to be installed alongside the main artifact, given by the file parameter.
- Type: java.io.File
- Since: 2.1
- Required: No
- User Property: pomFile
The bundled sources for the artifact.
- Type: java.io.File
- Since: 2.3
- Required: No
- User Property: sources
版本号
Version of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
- Type: java.lang.String
- Required: No
- User Property: version