一、下載java
http://maven.apache.org/download.cgiweb
二、解壓spring
三、配置環境變量apache
M2_HOME D:\program\apache-maven-3.3.3app
Path : %M2_HOME%\binjsp
四、驗證是否成功maven
打開命令行窗口,輸入mvn -version,顯示版本號,則安裝成功ide
我這裏遇到了錯誤: Unsupported major.minor version 51.0網站
這個是jdk版本太低形成的,maven3 要求至少jdk7,。插件
修改JAVA_HOME指向jdk1.7或者1.8,這個時候再執行mvn -v命令,仍是同樣的錯誤提示,重開命令行,從新執行,問題解決。
五、maven的倉庫地址是在D:\Program\apache-maven-3.0.4\conf 下的settings.xml 裏面配置的,
屬性名是localRepository
默認地址是:D:\個人文檔\.m2\repository
上面的路徑是我本身的電腦裏的配置
新安裝的3.3.9版,默認地址是C:\Users\he\.m2
六、執行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
七、能夠在maven網站上選擇jar包,並自動生成pom.xml裏的配置,複製便可
八、在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 ,若是報其餘的包更新失敗,也採起一樣的辦法
九、在命令行中想要操做指定的項目,須要首先進入須要構建的項目目錄,而後執行mvn的相關命令。
十、將jar包部署到jboss的方法
首先配置jboss的plugin,在pom.xml中添加如下語句
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-maven-plugin</artifactId> <version>1.5.0</version> <configuration> <jbossHome>E:\Program\jboss-eap-5.0\jboss-as</jbossHome> <serverName>default</serverName> </configuration> </plugin>
而後在項目目錄下執行命令
mvn clean install jboss:hard-undeploy jboss:hard-deploy jboss:start
十一、No persistence.xml file found in project
解決辦法:psersistence.xml要放在META-INF下面
十二、The method setApplicationContext(ApplicationContext) of type ApplicationContextUtils
must override a superclass method
解決辦法:將jdk版本從1.5換成1.6
1三、使用maven構建項目時報錯:gbk的不可映射字符
解決辦法:在編譯插件上添加配置項<encoding>utf8</encoding>,詳細代碼以下
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <source>1.6</source> <target>1.6</target> <encoding>utf8</encoding> </configuration> </plugin>
1四、Can not find the tag library descriptor for 「http://java.sun.com/jsp/jstl/core」
明明已經引入了jstl包,可是仍是報這個錯誤
解決辦法:把jstl的依賴刪除從新加入就行了
1五、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.
1六、webrootkey已經註冊
解決辦法,在web.xml文件裏添加參數
<context-param> <param-name>webAppRootKey</param-name> <param-value>cmes_web.root</param-value> </context-param>
1七、pom.xml中使用環境變量
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-maven-plugin</artifactId> <version>1.5.0</version> <configuration> <jbossHome>${env.JBOSS_HOME}</jbossHome> <serverName>default</serverName> </configuration> </plugin>