maven安装步骤并集成MyEclipse

1、下载maven插件

首先要安装myeclip10、jdk1.7 等环境变量,然后进行maven插件的安装配置,去官网http://maven.apache.org/下载最新版本的maven文件,在本文中,安装文件是apache-maven-3.6.3 (要求jdk1.7以上)

2、配置maven环境变量

将下载的文件进行解压缩,本文解压缩路径是D:\apache-maven-3.6.3-bin

然后配置环境变量,在系统变量中添加一个环境变量

变量名:MVN_HOME

变量值:D:\apache-maven-3.6.3-bin\apache-maven-3.1.1

在系统变量中找到Path 

在他的环境变量值中间加入:%MVN_HOME%\bin;

3、调试maven

打开命令提示符,maven环境是否有误。

mvn -v

如果能打印出maven的版本号,说明配置成功。

4、设置本地仓库配置

仓库用于存放项目所依赖的所有jar包。

我的仓库路径:D:\maven\repo,你可以将路径创建在任何位置。

打开D:\ apache-maven-3.1.1-bin\apache-maven-3.1.1\conf目录(安装目录)下的setting.xml文件,设置成创建的仓库路径

 

5、配置验证(成功)

打开命令提示符,输入:mvn help:system 

该命令会打印出所有的java系统属性和环境变量。如果运行的过程中没有错误,打开我们仓库(D:\maven\repo)会发现里面多了一些文件。这些文件就是我们从maven的中央仓库下载到本地仓库的。

PROCESSOR_ARCHITEW6432=AMD64

COMSPEC=C:\Windows\system32\cmd.exe

BUILDLAB=7601.win7sp1_ldr_escrow.190220-1800

=C:=C:\Users\lenovo

HOMEDRIVE=C:

LOGONSERVER=\\LENOVO-PC

PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 37 Stepping 5, GenuineIntel

COMMONPROGRAMFILES=C:\Program Files (x86)\Common Files

PROGRAMFILES=C:\Program Files (x86)

COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files

TEMP=C:\Users\lenovo\AppData\Local\Temp

NUMBER_OF_PROCESSORS=4

USERDOMAIN=lenovo-PC

PROCESSOR_LEVEL=6

ERROR_CODE=0

SESSIONNAME=Console

USERNAME=lenovo

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

WINDOWS_TRACING_FLAGS=3

BUILDLABEX=7601.24384.amd64fre.win7sp1_ldr_escrow.190220-1800

=EXITCODE=00000001

JVMCONFIG=\.mvn\jvm.config

PROCESSOR_REVISION=2505

PUBLIC=C:\Users\Public

USERPROFILE=C:\Users\lenovo

APPDATA=C:\Users\lenovo\AppData\Roaming

HOMEPATH=\Users\lenovo

LOCALAPPDATA=C:\Users\lenovo\AppData\Local

JAVA_HOME=D:\Java\jdk

ALLUSERSPROFILE=C:\ProgramData

MAVEN_CMD_LINE_ARGS=help:system

CLASSPATH=,;D:\Java\jdk\lib\dt.jar;D:\Java\jdk\lib\tools.jar

MAVEN_PROJECTBASEDIR=C:\Users\lenovo

 

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time:  07:06 min

[INFO] Finished at: 2020-01-04T23:45:53+08:00

[INFO] --------------------------------------------------------------------

C:\Users\lenovo>

6、配置验证(失败处理)

执行mvn help:system出现以下报错,则是仓库位置有错误:

[INFO] Scanning for projects…
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-clean-plugin:jar:2.5 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
[WARNING] The POM for org.apache.maven.plugins:maven-install-plugin:jar:2.4 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-install-plugin:jar:2.4 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] The POM for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-deploy-plugin:jar:2.7 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.pom
[WARNING] The POM for org.apache.maven.plugins:maven-site-plugin:jar:3.3 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-site-plugin/3.3/maven-site-plugin-3.3.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site-plugin:3.3 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-site-plugin:jar:3.3 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
[WARNING] The POM for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-antrun-plugin:jar:1.3 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom
[WARNING] The POM for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-beta-5 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[WARNING] The POM for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-dependency-plugin:jar:2.8 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-release-plugin/2.5.3/maven-release-plugin-2.5.3.pom
[WARNING] The POM for org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-release-plugin/2.5.3/maven-release-plugin-2.5.3.jar
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.5.3: Plugin org.apache.maven.plugins:maven-release-plugin:2.5.3 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-metadata.xml
Downloading from mirrorId: http://mvnrepository.com/org/codehaus/mojo/maven-metadata.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.293 s
[INFO] Finished at: 2018-07-17T18:28:05+08:00
[INFO] ------------------------------------------------------------------------

[ERROR] No plugin found for prefix ‘help’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (F:\mavenDownloadKu\download), mirrorId (http://mvnrepository.com/)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

把settings.xml中的mirror复制出来,修改成一下代码,问题出在了镜像服务器地址上,增加maven仓库的镜像地址。

<mirror> 

       <id>nexus-aliyun</id> 

       <mirrorOf>central</mirrorOf>   

       <name>Nexus aliyun</name> 

       <url>http://maven.aliyun.com/nexus/content/groups/public</url> 

    </mirror>

7、Myeclipse配置maven插件

安装好maven插件后需要在Myeclipse中进行配置,配置过程:打开Myeclipse, 进入window-preference-myeclipse-maven4myeclipse

设置maven安装路径

在安装路径中选择我们的maven文件,然后“apply”,最后点“OK”

8、设置maven本地库

在User Settings中选择我们maven中的seting.xml配置文件。选择后他的local Repository会自动变为我们配置文件中设定的路径。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值