您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > Maven管理的jar没有发布到WEB-INFlib下的解决方案
Maven管理的jar没有发布到WEB-INF/lib下的解决方案标准web工程在eclipse中利用m2eclipse插件添加依赖管理后,在部署过程中没有将依赖的jar包自动拷贝到/WEB-INF/lib中。参考了一些朋友的做法手动执行[java]viewplaincopy1.mvndependency:copy-dependencies-DoutputDirectory=src/main/webapp/WEB-INF/lib-DincludeScope=runtime命令将jar包拷贝到/WEB-INF/lib目录下。这种做法固然可以,但是也会带来一些不便。1、需要手动执行命令。2、不能时时更新。以下列出网上查找到的解决方法,m2eclipseplugin方式已验证通过。通过验证eclipse版本:eclipse-jee-helios-SR2-win32m2eclipse插件地址:标准web工程通过m2eclipse添加依赖管理步骤:1、“Maven”–“EnabledependencyManagement“2、WebDeploymentAssembly中添加mavendependencies步骤如下图:工程-右键-preferences.classpath文件中会有修改[xhtml]viewplaincopy1.classpathentrykind=conpath=org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER/为[xhtml]viewplaincopy1.classpathentrykind=conpath=org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER2.attributes3.attributename=org.eclipse.jst.component.dependencyvalue=/WEB-INF/lib/4./attributes5./classpathentry(执行“Maven”–“UpdateProjectConfiguration“未生效,故手动添加。必须deploy时候才会拷贝jar包到lib目录下,而非在更新maven依赖时候拷贝jar包。)以下为原文内容:Eclipse:WebDeploymentAssembly&MavendependenciesissuePublished:September3,2010,Updated:September3,2010,Author:mkyongprintProblemInEclipse3.5orearlyversion,inordertodeployedtheMavendependenciestothecorrect“/WEB-INF/lib”folder,youhavetoconfigurethedependenciesvia“JavaEEModuleDependencies”,andtheupdated“.classpath”filewilllooklikefollowing:File:“.classpath”,byJavaEEModuleDependencies…[xhtml]viewplaincopy1....2.classpathentrykind=varpath=M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar3.sourcepath=M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar4.attributes5.attributename=org.eclipse.jst.component.dependencyvalue=/WEB-INF/lib/6./attributes7./classpathentry8....SinceEclipse3.6,the“JavaEEModuleDependencies”isreplacedby“WebDeploymentAssembly”,butyoucandothesameviathe“ReferencedProjectsClasspathEntries”,however,itwillupdatethe“.classpath”fileasfollowing:File:“.classpath”,byWebDeploymentAssembly…[xhtml]viewplaincopy1....2.classpathentrykind=varpath=M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar3.sourcepath=M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar4.attributes5.attributename=org.eclipse.jst.component.dependencyvalue=..//6./attributes7./classpathentry8....Sadly,thedefault(value=”../”)makesalltheMaven’sdependenciesfailedtodeploy.SolutionNotabigissue,youstillcanmodifythe(value=”../”)to(value=”/WEB-INF/lib”)manually,butitwillgetoverrideeverytimeyourunaMavenbuild.Noworry,therearestillhavetwosolutions:1.WTPSupportIgnorethe“ReferencedProjectsClasspathEntries”settings,instead,maketheMavensupportsWTP2.0[java]viewplaincopy1.mvneclipse:eclipse-Dwtpversion=2.0Itwillgenerateanewfilenamed“org.eclipse.wst.common.component“,under“settings”folder,seeaportionofthisfile:File:“org.eclipse.wst.common.component”,byWTP[xhtml]viewplaincopy1....2.dependent-modulearchiveName=jsp-api-2.1.jardeploy-path=/WEB-INF/lib3.handle=module:/classpath/var/M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar4.dependency-typeuses/dependency-type5./dependent-module6....WithWTPsupport,ithelpstodeploytheMavendependenciesto“/WEB-INF/lib”foldercorrectly.2.m2eclipsepluginInstallthem2eclipse,anEclipseplugintointegrateMavenintotheEclipseIDE.Aftertheinstallation,rightclickontheprojectfolder,select“Maven”–“UpdateProjectConfiguration“,itwillupdatethe“.classpath”fileaccordingly,seeasnippetFile:“.classpath”,bym2eclipse[xhtml]viewplaincopy1....2.classpathentrykind=conpath=org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER3.attributes4.attributename=org.eclipse.jst.component.dependencyvalue=/WEB-INF/lib/5./attributes6./classpathentry7....IthelpstodeploytheMavendependenciescorrectlyaswell.Reference1.://://=msg&goto=542963&4.=msg&goto=543308&5.
本文标题:Maven管理的jar没有发布到WEB-INFlib下的解决方案
链接地址:https://www.777doc.com/doc-2882320 .html