1.下載Maven
地址:http://maven.apache.org/download.cgi
2.安裝Maven
系統變量:MAVEN_HOME = D:\maven\apache-maven-3.3.9
系統變量:path = %MAVEN_HOME%\bin
相信大家都有配過環境變量的,詳細步驟就不說了,對着把屬性名和屬性值配上的OK了。
打開 cmd,在里面敲:mvn -version
3.Eclipse設置
4.導入本地JAR
例如:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
把這份文件添加到pom.xml文件當中,工具就會自動下載其中的jar包。
如果添加網上maven資源中不存在的jar包的方法。
需要使用到命令:
mvn install:install-file -Dfile=%_jar% -DgroupId=%_gid% -DartifactId=%_aid% -Dversion=%_ver% -Dpackaging=%_pkg%
%_jar%:輸入jar的文件位置(本地文件的地址)
%_gid%:輸入groupid(一般都是jar包的名字)
%_aid%:輸入artifactid(和上面的差不多,范圍更細)
%_ver%:輸入version(版本號)
%_pkg%:輸入打包方式(默認方式是jar)
例子:
mvn install:install-file -Dfile=D:\Jar\vspherelib.jar -DgroupId=com.cpc -DartifactId=vsphere -Dversion=1.0 -Dpackaging=jar
然后打包成功。
之后jar包就會被導入到Maven Dependencies中,但是其中的jar還是在本地。