且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Maven webapp与Eclipse和WTP插件在Tomcat中以陌生的方式部署文件

更新时间:2023-11-17 21:03:34

你不应该乱手动创建面和Eclipse配置文件,这些文件应该从Maven POM派生。要这样做,请使用 maven-eclipse-plugin 来生成Eclipse使用您的Maven项目的特定文件,或使用 m2eclipse 插件,使Eclipse能够处理Maven项目。



这两种方法都提供Maven / Eclipse集成和支持WTP(即允许将项目识别为动态项目,而不是在服务器上运行。 。),但也不同。前者很轻,只生成Eclipse文件,后来提供了完整的集成,向导等,但更重。我一直是一个幸福的用户,使用一个或者它真的取决于你要找什么。



以防万一,如果你决定安装 m2eclipse,请确保安装可选的Maven Maven Integration for WTP 组件从m2eclipse Extras更新站点..


I use Eclipse J2EE 3.5 with Maven and tomcat. To deploy my maven webapp with WTP I added a Dynamic Web Module facet and changed the "org.eclipse.wst.common.component" file of the project because the webapp is not in a WebContent directory, here is the content of the file:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="toto">
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="toto"/>
<property name="java-output-path" value="/toto/target/classes"/>
</wb-module>
</project-modules>

But it never deploy the content correctly, in "workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\toto\" the directory structure is correct with WEB-INF and META-INF but empty, the jsp, html, css files are in "workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\toto\WEB-INF\classes\" with another WEB-INF and META-INF structure but with the files.

I don't understand this at all, thanks.

You shouldn't mess with facets and Eclipse configuration files manually, these files should be derived from the Maven POMs. To do so, either use the maven-eclipse-plugin to generate Eclipse specific files from your Maven project or use the m2eclipse plugin to make Eclipse able to deal with Maven projects.

Both approaches provide Maven/Eclipse integration and support the WTP (i.e. allow to get your project recognized as a dynamic project than you can Run on a Server...), but are also different. The former is very light and only generates Eclipse files, the later provides full integration, wizards, etc but is heavier. I've been an happy user of both, using one or the othe really depends of what you're looking for.

Just in case, if you decide to install m2eclipse, make sure to install the optional Maven Integration for WTP component from the the m2eclipse Extras update site..