2012-01-16 110 views
5

我們目前使用MyEclipse在開發過程中將項目部署到Tomcat。我們想轉儲MyEclipse並切換到WTP。我正在使用Eclipse 3.7。通過WTP將依賴項目部署到Tomcat

我們的項目佈局有一個'網絡'項目和'模塊'項目。

我希望能夠讓每個項目都有自己的ivy文件,使用IvyDE聲明其依賴關係,以創建依賴於這些jar的Eclipse庫,並將這些jar部署到WEB-INF/lib以及每個類中的類項目部署到WEB-INF /類。

我試過將'modules'項目聲明爲「Utility Module」,並將其ivy.xml文件中的jar作爲部署程序集的一部分聲明爲WEB-INF/lib,然後添加'modules'項目到'web'項目的部署程序集,但是我得到的是'web'項目的WEB-INF/lib中的一個名爲'modules.jar'的jar,其中包含'modules'項目的jar包( modules.jar)WEB-INF/lib目錄。

是否有可能獲得WTP從應用結構我要部署的佈局我想還是我必須對我的兩個項目重新組織成一個部署?如果是這樣,我該怎麼做?

回答

1

我不知道這是否有用,我完全不理解你的問題。

您可以告訴ivyDe將所有jar下載到特定的目錄。

  1. 請選中 「檢索...」 框
  2. 把相對路徑到你的WEB-INF/lib放到檢索模式,如:

    資源/ WEB-INF/lib目錄/ [神器] - [型] - [修改] [轉]

enter image description here

+0

感謝您抽出寶貴時間來幫助。這並不是我所期待的,我並不真的需要IvyDE來爲我做一個解決方案,在本地緩存中引用它們並沒有問題,WTP部署將從IvyDE創建的庫中部署它們。問題是'modules'項目引用的庫將被部署在WTP爲'modules'項目創建的jar中,而不是'web'項目的WAR-WEB-INF/lib中。我試圖找到一個解決方案,不需要我將'module'項目合併到'web'項目中,只是爲了讓WTP部署工作。 – Victor 2012-01-25 21:13:08

1

我相信我們有一個類似的配置你是什麼難以釋懷克設置。確保在「首選項」>「Ivy」>「類路徑」窗格中選中了「解決工作區中的依賴關係」。

與下面的設置,增加WarProject到Tomcat的時候,你應該看到WarProject節點上的[+]鏈接,並擴大它應該顯示JarProject節點。發佈時,你應該看到JarProject.jar任何廣口瓶定義在它的ivy.xml加入wtpwebapps/WarProject/WEB-INF/lib Tomcat的發佈目錄,這對我來說是在.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> 

罐項目的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> 

戰項目的.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" /> 

戰項目的.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> 

戰項目的.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> 

戰項目的常春藤.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.dependency屬性在常春藤類路徑容器中的類路徑條目,而是把它添加到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設置這一切了......

相關問題