Tomcat服务器中依赖项的Eclipse WTP部署的奇怪行为 [英] Strange behavior of Eclipse WTP deployment of dependencies in Tomcat server

查看:138
本文介绍了Tomcat服务器中依赖项的Eclipse WTP部署的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Eclipse WTP进行的Tomcat部署过程中,我有一个奇怪的行为. 我正在使用Eclipse 3.7(Indigo),WTP 3.3, m2eclipse插件,Java 1.6,Tomcat 5.5.

I have a strange behavior in the Tomcat deployment process made by my Eclipse WTP. I am using Eclipse 3.7 (Indigo), WTP 3.3, no m2eclipse plugin, Java 1.6, Tomcat 5.5.

我的应用程序是一个Web应用程序,具有一些其他项目作为依赖项以及一些第三方依赖项. 我的项目由Maven管理,当我们使用此工具构建应用程序时,一切正常.

My application is a web application that have some other projects as dependencies, as well as some third-parties dependencies. My project is managed by Maven, and everything works fine when we build the application using this tool.

要使用Eclipse处理项目,请运行mvn eclipse:clean eclipse:eclipse,然后在IDE中导入项目.

To work on my project using Eclipse, I run mvn eclipse:clean eclipse:eclipse and then, I import my projects in the IDE.

当我要在Tomcat 5.5服务器(此服务器由Eclipse管理)上部署此Web应用程序时,出现我的问题. 当我创建一个新的Tomcat服务器并在其中部署我的 my-project-portal 应用程序时,它仅添加了 my-project-xxx 依赖关系,另外还有三分-parties依赖关系(约有数百个定义中的9个). 在我的一位同事的桌面上(他正在使用Eclipse 3.5),根本没有部署任何第三方依赖性,只是 my-project-xxx JAR ...

My problem occurs when I want to deploy this web application on a Tomcat 5.5 server (this server is managed by Eclipse). When I create a new Tomcat server, and deploy my my-project-portal application in it, it only adds the my-project-xxx dependencies, as well as few third-parties dependencies (about 9 of the hundreds defined). On one of my colleagues desktop (he is using Eclipse 3.5), no third-parties dependency are deployed at all, just the my-project-xxx JAR...

但是,当我在 Java Build Path>库或"Deployment Assembly"中查看Web应用程序项目的属性时,依赖项列表是正确且完整的.

However, when I look at the web-app project properties, in Java Build Path > Libraries, or in "Deployment Assembly", the list of dependencies is correct and complete.

注释

我使用较旧的Eclipse(3.3,带有WTP 3.1)进行了一些测试,但没有遇到任何部署问题. 但是,此WTP仍在使用"Java EE模块依赖项",而最新的WTP版本不是这种情况.

I did some tests with an older Eclipse (3.3, with WTP 3.1) and I do not encounter any deployment issue. However, this WTP was still using the "Java EE Modules Dependencies", which is not the case of the latest WTP version.

直到现在,我们在mvn eclipse:eclipse之后使用了自定义Maven插件,该插件将所有依赖项(包括传递性依赖项)复制到my-webapp-project/WebContent/WEB-INF/lib中. 这样做,Eclipse自动部署了这些依赖项的内容,因此,我们将所有依赖项都存储在Tomcat服务器中.

Until now, we used a custom Maven plugin after the mvn eclipse:eclipse that copies all the dependencies (including transitives ones) into my-webapp-project/WebContent/WEB-INF/lib. Doing that, Eclipse automatically deployed the content of these dependencies, and thus, we got all the dependencies in the Tomcat server.

问题

  • 我的流程出了什么问题?
  • 我真的需要复制WEB-INF/lib目录中的所有依赖项吗?
  • 当我们想使用Eclipse在Tomcat服务器上部署Web应用程序时,正常过程是什么?
  • What is wrong with my process?
  • Do I really need to copy all the dependencies in the WEB-INF/lib directory?
  • What is the normal procedure when we want to deploy a web application on a Tomcat server, using Eclipse?

这是运行mvn eclipse:eclipse之后的Eclipse配置文件的摘录:

Here is an extract of my Eclipse configuration files after running mvn eclipse:eclipse:

.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src/main/java"/>
    <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/>
    <classpathentry kind="var" path="M2_REPO/asm/asm/2.2.2/asm-2.2.2.jar" sourcepath="M2_REPO/asm/asm/2.2.2/asm-2.2.2-sources.jar"/>
    <classpathentry kind="src" path="/my-project-business"/>
    ...
    <classpathentry kind="output" path="WebContent/WEB-INF/classes"/>
</classpath>

.settings/org.eclipse.wst.common.component

<project-modules id="moduleCoreId" project-version="1.5.0">
  <wb-module deploy-name="my-project-portal">
    <property name="context-root" value="my-project-portal"/>
    <wb-resource deploy-path="/" source-path="/WebContent"/>
    <property name="java-output-path" value="/WebContent/WEB-INF/classes"/>
    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar">
      <dependency-type>uses</dependency-type>
    </dependent-module>
    ...
    <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/my-project-business/my-project-business">
      <dependency-type>uses</dependency-type>
    </dependent-module>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
  </wb-module>
</project-modules>

推荐答案

我认为您存在配置错误的问题,因为:

I think you have a misconfiguration problem because:

  • 如果您的项目由maven管理,则无需使用此工具所需的依赖项来设置".classpath",例如,如果您需要一个不同的库或更改一个库的版本,则需要更新eclipse项目等中的配置.同上,"org.eclipse.wst.common.component"文件.

我认为您需要像@stivlo所说的那样安装对m2eclipse的WTP支持,当然要安装m2eclipse并检查您的项目配置,因为您需要删除这些文件中定义的所有依赖项.

I think you will need to install the WTP support for m2eclipse like @stivlo says, of course install the m2eclipse and review your project configuration, because you need to remove all the dependencies defined in those files.

现在,我从未将所有依赖项复制到/WEB-INF/lib目录中,因为我不想一直关注这些目录.例如,当我需要启动Tomcat时,m2eclipse插件会自动在相关的内部Eclipse目录中部署所有库和差异(即静态文件,类,资源文件等),就是这样,服务器从上下文启动,并包含所有需要的文件.为了方便起见,我一直在使用Eclipse中相关的插件.

Right now, I never copy all the dependencies in the /WEB-INF/lib directory, because I don't want to have to keep an eye on those directory. For example, when I need to start Tomcat, the m2eclipse plug-in deploys automatically all the libraries and differences (i.e static files, classes, resource files, etc) in the internal Eclipse directory related and that's it, the server starts with the context, with all the files needed. I'm always using the plugins related in Eclipse for convenience.

这篇关于Tomcat服务器中依赖项的Eclipse WTP部署的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆