Maven管理的jar没有发布到WEB-INF/lib下的解决方案
2014-05-04 15:41
435 查看
http://blog.163.com/ffwangkun@126/blog/static/16860101520133102430521/
原文:http://blog.csdn.net/yirentianran/article/details/6429240
标准web工程在eclipse中利用m2eclipse插件添加依赖管理后,在部署过程中没有将依赖的jar包自动拷贝到/WEB-INF/lib中。
参考了一些朋友的做法手动执行
[java] view plaincopy
mvn dependency:copy-dependencies -DoutputDirectory=src/main/webapp/WEB-INF/lib -DincludeScope=runtime
命令将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文件中会有修改
[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包。 )
以下为原文内容:
Eclipse : Web Deployment
Assembly & Maven dependencies issue
Published: September 3, 2010 , Updated: September 3, 2010 , Author: mkyong
print
will look like following :
File : “.classpath”, by Java EE Module Dependencies…
[xhtml] view plaincopy
...
<classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar"
sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
...
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…
[xhtml] view plaincopy
...
<classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar"
sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="../"/>
</attributes>
</classpathentry>
...
Sadly, the default (value=”../”) makes all the Maven’s dependencies failed to deploy.
[java] view plaincopy
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
[xhtml] view plaincopy
...
<dependent-module archiveName="jsp-api-2.1.jar" deploy-path="/WEB-INF/lib"
handle="module:/classpath/var/M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
...
With WTP support, it helps to deploy the Maven dependencies to “/WEB-INF/lib ” folder correctly.
click on the project folder, select “Maven ” –> “Update Project Configuration “, it will update the “.classpath ” file accordingly, see a snippet
File : “.classpath”, by m2eclipse
[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>
...
It helps to deploy the Maven dependencies correctly as well.
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
原文:http://blog.csdn.net/yirentianran/article/details/6429240
标准web工程在eclipse中利用m2eclipse插件添加依赖管理后,在部署过程中没有将依赖的jar包自动拷贝到/WEB-INF/lib中。
参考了一些朋友的做法手动执行
[java] view plaincopy
mvn dependency:copy-dependencies -DoutputDirectory=src/main/webapp/WEB-INF/lib -DincludeScope=runtime
命令将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文件中会有修改
[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包。 )
以下为原文内容:
Eclipse : Web Deployment
Assembly & Maven dependencies issue
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 ” filewill look like following :
File : “.classpath”, by Java EE Module Dependencies…
[xhtml] view plaincopy
...
<classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar"
sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
...
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…
[xhtml] view plaincopy
...
<classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar"
sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="../"/>
</attributes>
</classpathentry>
...
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[java] view plaincopy
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
[xhtml] view plaincopy
...
<dependent-module archiveName="jsp-api-2.1.jar" deploy-path="/WEB-INF/lib"
handle="module:/classpath/var/M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
...
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, rightclick on the project folder, select “Maven ” –> “Update Project Configuration “, it will update the “.classpath ” file accordingly, see a snippet
File : “.classpath”, by m2eclipse
[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>
...
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
相关文章推荐
- Maven管理的jar没有发布到WEB-INF/lib下的解决方案
- Maven管理的jar没有发布到WEB-INF/lib下的解决方案
- Maven管理的jar没有发布到WEB-INF/lib下的解决方案
- Maven管理的jar没有发布到WEB-INF/lib下的解决方案
- Maven管理的jar没有发布到WEB-INF/lib下的解决方案
- Maven管理的jar没有发布到WEB-INF/lib下的解决方案
- Maven管理的jar没有发布到WEB-INF/lib下的解决方案
- Maven项目发布之后发现jar包没有发布到WEB-INF/lib下的解决方案
- Maven管理的jar包不能发布到/WEB-INF/lib中
- tomcat部署后在web-inf下没有lib文件夹解决方案
- Maven 创建的Java Web项目部署后 WEB-INF/lib下没有jar包
- 解决 eclipse 在编译 打包 部署 maven 项目的时候 WEB-INF/lib 为空 没有 jar的问题
- tomcat发布时,WEB-INF/lib下没有jar包
- 解决eclipse中maven web工程打包成war(发布到tomcar)时lib中没有jar包的解决方法
- 在eclipse中引入maven web项目,jar包没有发布到tomcat的lib目录下的解决办法
- eclipse中maven web工程打包成war(发布到tomcar)时lib中没有jar包的解决办法
- Eclipse发布项目到服务器不会自动导没有放在WEB-INF/lib底下的jar包
- Eclipse部署Maven web项目到tomcat服务器时,没有将lib下的jar复制过去的解决办法
- 解决Servlet存在却报ClassNotFound问题——jar包放入WEB/INF/lib 与 userLibrary引入的区别
- 把jar包拷到WEB-INF/lib和放到工程之外的路径作为library引用有什么不同?