标准web工程在eclipse中利用m2eclipse插件添加依赖管理后,在部署过程当中没有将依赖的jar包自动拷贝到/WEB-INF/lib中。
html
参考了一些朋友的作法手动执行java
[java] view plaincopyios
mvn dependency:copy-dependencies -DoutputDirectory=src/main/webapp/WEB-INF/lib -DincludeScope=runtime web
命令将jar包拷贝到/WEB-INF/lib目录下。
这种作法当然能够,可是也会带来一些不便。
一、须要手动执行命令。
二、不能时时更新。app
如下列出网上查找到的解决方法,m2eclipse plugin方式已验证经过。
经过验证eclipse版本:eclipse-jee-helios-SR2-win32
m2eclipse插件地址:http://m2eclipse.sonatype.org/sites/m2e
标准web工程经过m2eclipse添加依赖管理步骤:
一、“Maven ” –> “Enable dependency Management“eclipse
二、Web Deployment Assembly中添加maven dependencieswebapp
步骤以下图:maven
工程 -> 右键 -> preferenceside
.classpath文件中会有修改spa
[xhtml] view plaincopy
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
为
[xhtml] view plaincopy
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
(执行“Maven ” –> “Update Project Configuration “未生效,故手动添加。必须deploy时候才会拷贝jar包到lib目录下,而非在更新maven依赖时候拷贝jar包。 )