日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 将依赖打包进lib_maven把依赖包拷贝到lib下

發(fā)布時間:2023/12/20 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 将依赖打包进lib_maven把依赖包拷贝到lib下 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

標準web工程在eclipse中利用m2eclipse插件添加依賴管理后,在部署過程中沒有將依賴的jar包自動拷貝到/WEB-INF/lib中。

參考了一些朋友的做法手動執(zhí)行

mvn?dependency:copy-dependencies?-DoutputDirectory=src/main/webapp/WEB-INF/lib??-DincludeScope=runtime

命令將jar包拷貝到/WEB-INF/lib目錄下。

這種做法固然可以,但是也會帶來一些不便。

1、需要手動執(zhí)行命令。

2、不能時時更新。

以下列出網(wǎng)上查找到的解決方法,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文件中會有修改

(執(zhí)行“Maven ” –> “Update Project Configuration “未生效,故手動添加。必須deploy時候才會拷貝jar包到lib目錄下,而非在更新maven依賴時候拷貝jar包。 )

以下為原文內(nèi)容:

Published: September 3, 2010 , Updated: September 3, 2010 , Author: mkyong

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…

...

sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">

...

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…

...

sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">

...

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

mvn?eclipse:eclipse?-Dwtpversion=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

...

handle="module:/classpath/var/M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar">

uses

...

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://blog.csdn.net/yirentianran/article/details/6429240

總結

以上是生活随笔為你收集整理的java 将依赖打包进lib_maven把依赖包拷贝到lib下的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。