Eclipse和外部src和web内容文件夹的链接或映射 [英] Eclipse and external src and web content folder linking or mapping

查看:215
本文介绍了Eclipse和外部src和web内容文件夹的链接或映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这不是问题,而是解决了我遇到的问题,浪费了4,5个小时来找出解决方案。请允许我知道如果有更好的替代方案来管理eclipse项目的外部src文件夹。



我正在使用版本控制系统(GIT)来管理我的项目。使用外部Git客户端访问存储库(SourceTree)



注意: SVN和turtoise也可以使用相同的场景。 / p>

在Eclipse中:当我创建一个动态的Web项目时,它也包含了src和WebContent文件夹,而我想使用外部文件夹使用Git客户端从Git Repo进行结帐)....我在google上做了大量的搜索,以映射或链接外部src和WebContent文件夹,但没有找到方法。最后我得到了成功。在这里发布这些信息....所以可能对某人有用。



(1)假设您已经在C:\MyGitRepo\ 它有2个文件夹src和WebContent



(2)在eclipse中创建动态Web项目:将源文件夹名称设置为src2



源文件夹映射



(3)右键单击项目 - >新建 - >文件夹 - >提前 - >链接到替代位置 - >C:\MyGitRepo\src



(3)右键单击项目 - >新建 - >源文件夹 - >浏览器 - >src



(4)删除Src2



Web内容文件夹(5)删除现有的WebContent文件夹



(6)右键单击在项目 - >新建 - >文件夹 - >高级 - >链接到替代位置 - >C:\MyGitRepo\WebContent



(7)项目属性 - >部署程序集 - >添加文件夹 - >下一步 - >选择WebContent文件夹



一切正常...意味着您的工作区中没有src和web内容文件夹,而您正在使用外部文件夹



我们可以使用eclipse插件,但是使用外部客户端(turtoise SVN或源码树)更方便。

解决方案

当您在eclipse中创建动态项目时,它基本上将项目的设置存储在./settings/org.eclipse.wst.common.component中。这在包资源管理器中是不可见的,您需要使用导航器来访问。



以下是我创建的演示项目的示例:



文件:org.eclipse.wst.common.component

 <?xml version =1.0 encoding =UTF-8?> 
< project-modules id =moduleCoreIdproject-version =1.5.0>
< wb-module deploy-name =demo>
< wb-resource deploy-path =/source-path =/ WebContenttag =defaultRootSource/>
< wb-resource deploy-path =/ WEB-INF / classessource-path =/ src/>
< property name =context-rootvalue =demo/>
< property name =java-output-pathvalue =/ demo / build / classes/>
< / wb-module>
< / project-modules>

如你所见,有一个xml标签< wb-resource deploy -path =/source-path =/ WebContenttag =defaultRootSource/> 在那里,您可以定义包含Web资源的webContent目录(html,jsp,aspx,js,等等)



下一行< wb-resource deploy-path =/ WEB-INF / classessource-path =/ src/> 告诉Java类所在的路径。这也可以编辑为您选择的源文件夹。



完成之后,请遵循以下步骤:


  1. 右单击您的项目>属性。

  2. 在首选项窗口中转到Java构建路径。

  3. 单击源选项卡,删除现有的src文件夹和
    需要一个。

  4. 完成更改后,检查版本
    控件中的设置文件。

每次结帐都会解决问题。



如果有帮助,请通知我。



Himanshu


First thing this is not the question but the solution of the problem which I have faced and waste 4,5 hours to find out the solution. please let me know if there is any better alternative to manage the external src folder with eclipse project.

I am using a version version control system (GIT) to manage my project. Also accessing the Repository using the external Git client (SourceTree)

Note : Same scenario can be possible with SVN and tortoise SVN as well.

In Eclipse : when I am creating a dynamic web project, it also content the "src" and "WebContent" folder, while i want to use the external folder (which I have checkout from Git Repo using Git client) .... I did lots of searching on google to map or link the external src and WebContent folder but not found the way. finally I have got the success. posting this information here .... so may be useful for someone.

(1) Assume you have check out the content at location "C:\MyGitRepo\" which having 2 folder "src" and "WebContent"

(2) create dynamic web project in eclipse : set source folder name to "src2"

Source folder mapping

(3) Right click on project -> New -> folder -> advance -> link to alternative location -> "C:\MyGitRepo\src"

(3) Right click on project -> New -> Source folder -> browser -> "src"

(4) Delete the "Src2"

Web Content folder mapping

(5) Delete the existing "WebContent" folder

(6) Right click on project -> New -> folder -> advance -> link to alternative location -> "C:\MyGitRepo\WebContent"

(7) project property -> Deployment assembly -> Add folder -> next -> select "WebContent" folder

Everything work fine... means there is no src and web content folder in your workspace and you are using the external one

We can use the eclipse plugin as well to do so but it is more convenient to use the external client (tortoise SVN or source tree)

解决方案

When you create a dynamic projects in eclipse it basically stores the settings of the project in ./settings/org.eclipse.wst.common.component. This is not viewable in package explorer you need to use navigator to access that.

Below is the example from the demo project I created:

File : org.eclipse.wst.common.component

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="demo">
        <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
        <property name="context-root" value="demo"/>
        <property name="java-output-path" value="/demo/build/classes"/>
    </wb-module>
</project-modules>

As you can see there is an xml tag <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/> there you can define your webContent directory which contains your web resources (html, jsp, aspx, js, etc.)

The next line <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/> is telling the path where java classes resides. This can be edited to your choice of source folder as well.

Once you are done with that please folow the steps below :

  1. Right click your project > properties.
  2. Go to Java Build Path in the preferences window.
  3. Click the source tab and remove the existing src folder and your desired one.
  4. Once done with changes checkin the settings file in the version control.

Problem solved for every checkout.

Let me know if that helped.

Thanks Himanshu

这篇关于Eclipse和外部src和web内容文件夹的链接或映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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