Eclipse : Web Deployment Assembly & Maven dependencies issue
標準web工程在eclipse中利用m2eclipse外掛新增依賴管理後,在部署過程中沒有將依賴的jar包自動拷貝到/WEB-INF/lib中。
參考了一些朋友的做法手動執行
命令將jar包拷貝到/WEB-INF/lib目錄下。
這種做法固然可以,但是也會帶來一些不便。
1、需要手動執行命令。
2、不能時時更新。
以下列出網上查詢到的解決方法,m2eclipse plugin方式已驗證通過。
通過驗證eclipse版本:eclipse-jee-helios-SR2-win32
m2eclipse外掛地址:http://m2eclipse.sonatype.org/sites/m2e
標準web工程通過m2eclipse新增依賴管理步驟:
1、“Maven ” –> “Enable dependency Management“
2、Web Deployment Assembly中新增maven dependencies
步驟如下圖:
工程 -> 右鍵 -> preferences
.classpath檔案中會有修改
為
(執行“Maven ” –> “Update Project Configuration “未生效,故手動新增。必須deploy時候才會拷貝jar包到lib目錄下,而非在更新maven依賴時候拷貝jar包。 )
以下為原文內容:
Eclipse : Web Deployment Assembly & Maven dependencies issue
Problem
In Eclipse 3.5 or early version, in order to deployed the Maven dependencies to the correct “/WEB-INF/lib ” folder, you have to configure the dependencies via “Java EE Module Dependencies”, and the updated “.classpath ” file will look like following :
File : “.classpath”, by Java EE Module Dependencies…
Since Eclipse 3.6, the “Java EE Module Dependencies” is replaced by “Web Deployment Assembly”, but you can do the same via the “Referenced Projects Classpath Entries”, however, it will update the “.classpath ” file as following :
File : “.classpath”, by Web Deployment Assembly…
Sadly, the default (value=”../”) makes all the Maven’s dependencies failed to deploy.
Solution
Not a big issue, you still can modify the (value=”../”) to (value=”/WEB-INF/lib”) manually, but it will get override every time you run a Maven build. No worry, there are still have two solutions :
1. WTP Support
Ignore the “Referenced Projects Classpath Entries” settings, instead, make the Maven supports WTP 2.0
It will generate a new file named “org.eclipse.wst.common.component “, under “settings ” folder, see a portion of this file :
File : “org.eclipse.wst.common.component”, by WTP
With WTP support, it helps to deploy the Maven dependencies to “/WEB-INF/lib ” folder correctly.
2. m2eclipse plugin
Install the m2eclipse , an Eclipse plugin to integrate Maven into the Eclipse IDE. After the installation, right click on the project folder, select “Maven ” –> “Update Project Configuration “, it will update the “.classpath ” file accordingly, see a snippet
File : “.classpath”, by m2eclipse
It helps to deploy the Maven dependencies correctly as well.
Reference
- http://m2eclipse.sonatype.org/
- http://www.mkyong.com/maven/maven-dependency-libraries-not-deploy-in-eclipse-ide/
- http://www.eclipse.org/forums/index.php?t=msg&goto=542963&
- http://www.eclipse.org/forums/index.php?t=msg&goto=543308&
- http://tux2323.blogspot.com/2010/06/review-eclipse-helios-rc4.html
相關文章
- eclipse中maven專案不顯示Maven Dependencies依賴EclipseMaven
- Maven EclipseMavenEclipse
- maven建立Java 和 Web Project, 並匯入EclipseMavenJavaWebProjectEclipse
- Maven - Maven-dependency-plugin (goals "copy-dependencies","unpack") is not supportedMavenPluginGo
- Maven專案無法引入 Maven Dependencies Libraries 問題Maven
- Apache Maven Assembly Plugin 的介紹ApacheMavenPlugin
- web assembly 初體驗Web
- maven </dependencies>和</dependencyManagement> 有什麼區別Maven
- Maven教程(Eclipse配置及maven專案)MavenEclipse
- Eclipse配置maven環境EclipseMaven
- 在eclipse中maven配置EclipseMaven
- Maven+Eclipse工程搭建MavenEclipse
- 008 Web Assembly之效能分析Web
- 使用Maven打包你的應用——maven-jar-plugin & maven-assembly-plugin & maven-shade-pluginMavenJARPlugin
- Could not load file or assembly or one of its dependencies 試圖載入格式不正確的程式
- Apache Maven Assembly自定義打包外掛的使用ApacheMaven
- 006 Web Assembly之除錯方法Web除錯
- Eclipse-用Eclipse搭建一個maven專案-續EclipseMaven
- 009 Web Assembly學習結束篇Web
- Eclipse中專案Maven相關配置EclipseMaven
- eclipse maven打包 跳過junit測試EclipseMaven
- web assembly是什麼,能幹什麼Web
- 004 Web Assembly康威遊戲之優化Web遊戲優化
- 007 Web Assembly康威遊戲新增互動Web遊戲
- 用Idea建立第一個spring web專案,一直resolving dependencies XXX (載入特別慢http://repo1.maven.org/maven2)IdeaSpringWebHTTPMaven
- 【Maven實戰技巧】「外掛使用專題」Maven-Assembly外掛實現自定義打包Maven
- eclipse 手動新增jar包到maven庫EclipseJARMaven
- 解決eclipse的maven依賴報錯EclipseMaven
- windows平臺,eclipse安裝maven外掛WindowsEclipseMaven
- Maven:如何在eclipse中使用mvn clean install?MavenEclipse
- 如何建立一個Maven專案(eclipse版本)MavenEclipse
- 004 Web Assembly康威遊戲之最佳化Web遊戲
- More web function requests go online concurrently, and web service deployment is faster and more economical!WebFunctionGoAST
- Maven Web 應用MavenWeb
- 01 Eclipse使用Maven慢的問題解決EclipseMaven
- 005 Web Assembly之測試康威遊戲程式碼Web遊戲
- issue
- 第六記·Linux中安裝eclipse、配置maven並使用maven搭建小工程LinuxEclipseMaven
- Dynamic Web Project option missing in Eclipse KeplerWebProjectEclipse