当我安装一个jar时,pom就像
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<configuration>
<groupId>org.oracle</groupId>
<artifactId>oraclejdbc</artifactId>
<version>14</version>
<packaging>jar</packaging>
<file>${basedir}/libs/ojdbc14.jar</file>
</configuration>
<executions>
<execution>
<id>install-jar-lib</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
然后
mvn install:install-file
它有效,但我想安装一些罐子不仅一个,所以我编辑像
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-artifacts.1</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>clean</phase>
<configuration>
<groupId>org.oracle</groupId>
<artifactId>oraclejdbc</artifactId>
<packaging>jar</packaging>
<version>14</version>
<file>${basedir}/libs/ojdbc14.jar</file>
</configuration>
</execution>
<execution>
<id>install-artifacts.2</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>clean</phase>
<configuration>
<file>${basedir}/libs/sqljdbc4.jar</file>
<groupId>com.microsoft.sqlserver</groupId>
<packaging>jar</packaging>
<artifactId>sqljdbc</artifactId>
<version>1.0</version>
</configuration>
</execution>
</executions>
</plugin>
然后
mvn install:install-file
但是,控制台显示
无法在项目核心上执行目标org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file(default-cli):目标org.apache.maven的参数'file'。插件:maven-install-plugin:2.5.2:安装文件丢失或无效 - &gt; [帮助1]
我该怎么办?谢谢!
答案 0 :(得分:1)
从命令行执行时,目标需要参数file
,该参数可以提供为:
mvn install:install-file -Dfile=.../libs/ojdbc14.jar
或者使用pom.xml
中指定的相同配置,您只需执行
mvn install
另外,请注意,其中一个执行中的artifactId似乎无效
<file>${basedir}/libs/sqljdbc4.jar</file>
<groupId>com.microsoft.sqlserver</groupId>
<packaging>jar</packaging>
<artifactId>sqljdbc</artifactId> <!--this might be sqljdbc4-->
当您没有第三方工件的POM时,您可以关注generic pom generation并使用
mvn install:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DgeneratePom=true