5

我们目前正在使用 MyEclipse 在开发过程中将我们的项目部署到 Tomcat。我们想转储 MyEclipse 并切换到 WTP。我正在使用 Eclipse 3.7。

我们的项目布局有一个“网络”项目和一个“模块”项目。

我希望能够让每个项目都有自己的 ivy 文件,使用 IvyDE 声明其依赖项,以创建依赖于这些 jar 的 Eclipse 库,并将这些 jar 部署到 WEB-INF/lib 并将每个项目中的类部署到 WEB -INF/类。

我尝试将“模块”项目声明为“实用程序模块”,并将其 ivy.xml 文件中的 jar 作为部署程序集的一部分声明到 WEB-INF/lib,然后将“模块”项目添加到部署程序集的'web'项目,但我得到的是'web'项目的WEB-INF / lib中一个名为'modules.jar'的jar,其中包含'modules'项目的jar(modules.jar) WEB-INF/lib 目录。

是否有可能让 WTP 从我拥有的应用程序结构部署到我想要的部署布局,或者我是否必须将我的两个项目重组为一个?如果是这样,我会怎么做?

4

2 回答 2

1

我不知道这是否会有所帮助,我不完全理解你的问题。

您可以告诉 ivyDe 将所有 jar 下载到特定目录。

  1. 选中“检索...”框
  2. 将 WEB-INF/lib 的相对路径放入检索模式中,例如:

    资源/WEB-INF/lib/[artifact]-[type]-[revision].[ext]

在此处输入图像描述

于 2012-01-25T13:44:10.273 回答
1

我相信我们的配置与您尝试设置的配置类似。确保在 Preferences > Ivy > Classpath 窗格中选中了“Resolve dependencies in workspace”。

使用下面的设置,将 WarProject 添加到 Tomcat 时,您应该会在 WarProject 节点上看到一个 [+] 链接,展开它应该会显示 JarProject 节点。发布时,您应该会看到JarProject.jar其中定义的任何 jar 都已ivy.xml添加到wtpwebapps/WarProject/WEB-INF/libTomcat 的发布目录中,对我而言,该目录位于.metadata/.plugins/org.eclipse.wst.server.core/tmp0我的工作区目录下。

Jar 项目的 .settings/org.eclipse.wst.common.project.facet.core.xml:

<faceted-project>
  <fixed facet="jst.java" />
  <fixed facet="jst.utility" />
  <installed facet="jst.java" version="1.6" />
  <installed facet="jst.utility" version="1.0" />
</faceted-project>

Jar 项目的 .settings/org.eclipse.wst.common.component:

<project-modules id="moduleCoreId" project-version="1.5.0">
  <wb-module deploy-name="JarProject">
    <wb-resource deploy-path="/" source-path="/src" />
    <wb-resource deploy-path="/" source-path="/resources" />
  </wb-module>
</project-modules>

Jar 项目的 ivy.xml:

<ivy-module
    version="2.0"
    xmlns:m="http://ant.apache.org/ivy/maven"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
  <info module="JarProject" organisation="org.whatever" revision="${revision}" />
  <configurations>
      <conf name="local" visibility="private"
        description="Artifacts necessary for local development and testing" />
      <conf name="master" />
      <conf name="sources" />
  </configurations>
  <publications>
      <artifact ext="pom" type="pom" />
      <artifact ext="jar" type="jar" conf="master" />
      <artifact ext="jar" type="source" conf="sources" m:classifier="sources" />
  </publications>

  <dependencies defaultconfmapping="*->master(default),runtime()">
    <dependency org="org.jdom" name="jdom" rev="1.0" conf="master" />
    <dependency org="junit" name="junit-dep" rev="4.9" conf="local" />
  </dependencies>
</ivy-module>

War项目的.settings/org.eclipse.wst.common.project.facet.core.xml:

<faceted-project>
  <fixed facet="jst.java" />
  <fixed facet="jst.web" />
  <installed facet="jst.java" version="1.6" />
  <installed facet="jst.web" version="2.5" />
  <runtime name="Apache Tomcat v6.0" />

War项目的.settings/org.eclipse.wst.common.component:

<project-modules id="moduleCoreId" project-version="1.5.0">
  <wb-module deploy-name="WarProject">
    <property name="context-root" value="WarProject" />
    <wb-resource deploy-path="/" source-path="/WebContent" />
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src" />
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/resources" />
  </wb-module>
</project-modules>

War项目的.classpath:

<classpath>
  <classpathentry kind="output" path="bin" />
  <classpathentry kind="src" path="src" />
  <classpathentry kind="src" path="resources" />
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
    <attributes>
      <attribute name="owner.project.facets" value="jst.java" />
    </attributes>
  </classpathentry>
  <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
    <attributes>
      <attribute name="owner.project.facets" value="jst.web" />
    </attributes>
  </classpathentry>
  <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&amp;confs=local&amp;ivySettingsPath=%24%7Bworkspace_loc%3AWarProject%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=" />
  <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&amp;confs=master&amp;ivySettingsPath=%24%7Bworkspace_loc%3AWarProject%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=">
    <attributes>
      <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib" />
    </attributes>
  </classpathentry>
  <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" />
</classpath>

War项目的ivy.xml:

<ivy-module
    version="2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
  <info module="WarProject" organisation="org.whatever" revision="${revision}" />
  <configurations>
    <conf name="local" visibility="private"
      description="Artifacts necessary for local development and testing" />
    <conf name="master" />
  </configurations>

  <dependencies defaultconfmapping="*->master(default),runtime()">
    <dependency org="org.whatever" name="JarProject" rev="latest.integration" changing="true" conf="master" />
    <!-- and other dependencies of the war project -->
  </dependencies>
</ivy-module>

我还发现可以省略org.eclipse.jst.component.dependencyIvy 类路径容器的类路径条目中的属性,而是将其添加到org.eclipse.wst.common.component文件中,如下所示:

<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/con/org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&amp;confs=master&amp;ivySettingsPath=%24%7Bworkspace_loc%3AWarProject%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;propertyFiles=">
  <dependency-type>consumes</dependency-type>
</dependent-module>

但是在这种替代方案下,如果我更改 ivy.xml 并运行解析,部署的 webapp 并不会很好地更新。此外,对 Ivy 的 URL 参数的任何更改都需要与这两个文件保持同步,否则不会对部署程序集做出任何贡献。

不知道如何通过 UI 设置所有这些...

于 2012-04-04T19:57:04.460 回答