1、下载
2、解压
3、配置环境变量
M2_HOME D:\program\apache-maven-3.3.3
Path : %M2_HOME%\bin
4、验证是否成功
打开命令行窗口,输入mvn -version,显示版本号,则安装成功
我这里遇到了错误: Unsupported major.minor version 51.0
这个是jdk版本过低造成的,maven3 要求至少jdk7,。
修改JAVA_HOME指向jdk1.7或者1.8,这个时候再执行mvn -v命令,还是一样的错误提示,重开命令行,重新执行,问题解决。
5、maven的仓库地址是在D:\Program\apache-maven-3.0.4\conf 下的settings.xml 里面配置的,
属性名是localRepository 默认地址是:D:\我的文档\.m2\repository 上面的路径是我自己的电脑里的配置新安装的3.3.9版,默认地址是C:\Users\he\.m2
6、执行run as-maven install时报错
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
检查环境变量已经配置了,在控制台输入mvn命令也有效。
解决办法是修改MyEclipse的配置,
在Window->Preference->Java->Installed JREs->Edit
在Default VM arguments中设置
-Dmaven.multiModuleProjectDirectory=$M2_HOME
7、可以在maven网站上选择jar包,并自动生成pom.xml里的配置,复制即可
地址:
8、在MyEclipse中创建maven项目之后报下面的错误
Failure to transfer org.codehaus.plexus:plexus-io:jar:1.0 from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-io:jar:1.0 from/to central (http://repo1.maven.org/maven2): No response received after 60000
这个错误是更新jar包失败,解决办法是去本地仓库删掉对应的包,然后在项目上点击右键->Maven4MyEclipse->Update Dependencies ,如果报其他的包更新失败,也采取同样的办法
9、在命令行中想要操作指定的项目,需要首先进入需要构建的项目目录,然后执行mvn的相关命令。
10、将jar包部署到jboss的方法
首先配置jboss的plugin,在pom.xml中添加以下语句
org.codehaus.mojo jboss-maven-plugin 1.5.0 E:\Program\jboss-eap-5.0\jboss-as default
然后在项目目录下执行命令
mvn clean install jboss:hard-undeploy jboss:hard-deploy jboss:start
11、No persistence.xml file found in project
解决办法:psersistence.xml要放在META-INF下面
12、The method setApplicationContext(ApplicationContext) of type ApplicationContextUtils
must override a superclass method 解决办法:将jdk版本从1.5换成1.613、使用maven构建项目时报错:gbk的不可映射字符
解决办法:在编译插件上添加配置项<encoding>utf8</encoding>,详细代码如下
org.apache.maven.plugins maven-compiler-plugin 2.3.1
14、Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”
明明已经引入了jstl包,但是还是报这个错误
解决办法:把jstl的依赖删除重新加入就好了
15、VERSION OF SPRING FACET COULD NOT BE DETECTED.
The migration process needs to detect the correct version of Spring support used by a project. If the process fails to detect the version based on containers used by the project, it tries to read it from the .springBeans file. If the file is missing, the migration process is unable to continue.You need to manually create the file in the root of the project, before invoking the Migration wizard. To do so, right-click the project, and select New>File from the menu. Enter .springBeans as the file name, and click Finish. The .springBeans file editor should open. Paste the following code into it, and save the file.
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription> <springVersion>2.0</springVersion> </beansProjectDescription>Now you can rerun the migration process by selecting MyEclipse>Migrate Projects from theMyEclipsemenu, or run the process from the Project Migration view.
Note: The .springBeans file might not appear in the Package Explorer view; you will need to disable the.* resources filter to see it. To do so, click the white triangle (View menu) in the top-right corner of the Package Explorer view and select Filters. Next, deselect the .* resources filter, and click OK. You should now be able to see the .springBeans file.
16、webrootkey已经注册
解决办法,在web.xml文件里添加参数
webAppRootKey cmes_web.root
17、pom.xml中使用环境变量
org.codehaus.mojo jboss-maven-plugin 1.5.0 ${env.JBOSS_HOME} default