Eclipse 和 Tomcat:如何指定项目提供的文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/202253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse & Tomcat: How to specify which folder is served from the project?
提问by Ville Salonen
I'm using Eclipse 3.4 and Tomcat 5.5 and I have a Dynamic Web Project set up. I can access it from http://127.0.0.1:8080/project/but by default it serves files from WebContent folder. The real files, that I want to serve, can be found under folder named "share". This folder comes from CVS so I'd like to use it with its given name instead of renaming it. How can this be done?
我正在使用 Eclipse 3.4 和 Tomcat 5.5,并且我设置了一个动态 Web 项目。我可以从http://127.0.0.1:8080/project/访问它,但默认情况下它提供来自 WebContent 文件夹的文件。我想要提供的真实文件可以在名为“share”的文件夹下找到。这个文件夹来自 CVS,所以我想使用它的给定名称而不是重命名它。如何才能做到这一点?
回答by matt b
In the project folder, there should be a file under the .settings
folder named org.eclipse.wst.common.component
that contains an XML fragment like this:
在项目文件夹中,该.settings
文件夹下应该有一个文件org.eclipse.wst.common.component
,其中包含一个像这样的 XML 片段:
<wb-module deploy-name="WebProjectName">
<wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
You should be able to change the source-path under wb-resource
to your share folder. I'd make these changes with the Eclipse project closed to be safe.
您应该能够更改wb-resource
共享文件夹下的源路径。为了安全起见,我会在关闭 Eclipse 项目的情况下进行这些更改。
This is a setting that you pick when you first create the Dynamic Web Project in Eclipse - I can't find how to change the value in an existing project thru Eclipse itself.
这是您第一次在 Eclipse 中创建动态 Web 项目时选择的设置 - 我找不到如何通过 Eclipse 本身更改现有项目中的值。
If you want the share folder to be mapped to a different path when deployed, such as /share/
in your webapp, you can probably just add another wb-resource element.
如果您希望在部署时将共享文件夹映射到不同的路径,例如/share/
在您的 web 应用程序中,您可能只需添加另一个 wb-resource 元素。
回答by user705663
Can be done through Eclipse, no need to manually edit .settings files.
可以通过 Eclipse 完成,无需手动编辑 .settings 文件。
In Eclipse 3.6 (and possibly earlier releases),
在 Eclipse 3.6(可能还有更早的版本)中,
- right click on your project
- click on properties
- Click on 'Deployment Assembly'
- Add... Folder -> Next
- Navigate to source folder
- Finish
- 右键单击您的项目
- 点击属性
- 单击“部署程序集”
- 添加...文件夹 -> 下一步
- 导航到源文件夹
- 结束
回答by anjanb
if you're running windows, use the junction utility from MS : http://technet.microsoft.com/en-us/sysinternals/bb896768.aspxand map your share directory to the Webcontent folder. I've regularly done several of these mappings quite regularly.
如果您运行的是 Windows,请使用 MS 的连接实用程序:http: //technet.microsoft.com/en-us/sysinternals/bb896768.aspx并将您的共享目录映射到 Webcontent 文件夹。我经常定期完成其中的几个映射。
回答by Adugna
On STS 2.5.1
在 STS 2.5.1 上
- right click on your project
- click on properties
- Click on 'Java Build path'
- Click "Source" tab
- Navigate to default out put folder
- Browse and add your path
- Finish
- 右键单击您的项目
- 点击属性
- 单击“Java 构建路径”
- 单击“来源”选项卡
- 导航到默认输出文件夹
- 浏览并添加您的路径
- 结束
回答by Vinay Taneja
you can specify location of webcontent in R-click on project > Properties > Deployment Assembly
您可以在 R 中指定 webcontent 的位置,然后单击项目 > 属性 > 部署程序集
This is what I did in mys STS, you can add or remove a location.
这就是我在我的 STS 中所做的,您可以添加或删除位置。