maven(二)----maven添加jar包到本地仓库及到项目中

maven 构建项目时,可能会引用到一些公司的其他项目。或引用的jar 包在maven 主仓库加载不到。

这时我们可以将我们需要的jar 包安装到本地仓库中。方法如下。

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>3.1.0.RELEASE</version>
</dependency>

Maven 安装 JAR 包的命令是:

mvn install:install-file -Dfile=jar包的位置 -DgroupId=上面的groupId -DartifactId=上面的artifactId -Dversion=上面的version -Dpackaging=jar

例如:
我下载的这个 jar 包是放到了 D:\mvn 目录下(D:\mvn\spring-context-support-3.1.0.RELEASE.jar)
那么我在 cmd 中敲入的命令就应该是:

mvn install:install-file -Dfile=D:\mvn\spring-context-support-3.1.0.RELEASE.jar -DgroupId=org.springframework -DartifactId=spring-context-support -Dversion=3.1.0.RELEASE -Dpackaging=jar


当然也可以直接加入到项目中

<dependency>
            <groupId>struts</groupId>
            <artifactId>struts</artifactId>
            <version>1.3.10</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/javabuilder.jar</systemPath>
< /dependency>

猜你喜欢

转载自blog.csdn.net/u010775025/article/details/80649438