Eclipse - 发布和运行简单的 Web 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8535144/
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 - Publish & Run Simple Web Project
提问by blankabout
I must be missing something really obvious but I just cannot work out how to publish & run a simple JavaScript & HTML project to an Apache server on a local VM.
我一定遗漏了一些非常明显的东西,但我无法弄清楚如何在本地 VM 上向 Apache 服务器发布和运行一个简单的 JavaScript 和 HTML 项目。
I have tried the locally installed Eclipse help but it always seems to come to an end without filling in the full details of what is required and there is no summary that gives a start to finish overview of what is needed to complete what should be a straightforward task.
我已经尝试了本地安装的 Eclipse 帮助,但它似乎总是在没有填写所需内容的完整细节的情况下结束,并且没有摘要给出完成应该是简单的内容所需的内容的开始到结束的概述任务。
My project is simple, it is comprised of links to a single JavaScript file and a directory of HTML files. I have created a server, giving the details of the Apache server on the VM, as far as I can tell I now need to link the project with the server but I can't work out how to do this task. If I right click on the project and go to Run As/Configurations
the Create, manage and run configurations
window allows me to create a new configuration but the server select box contains no servers.
我的项目很简单,它由指向单个 JavaScript 文件的链接和一个 HTML 文件目录组成。我已经创建了一个服务器,提供了 VM 上 Apache 服务器的详细信息,据我所知,我现在需要将项目与服务器链接,但我不知道如何执行此任务。如果我右键单击项目并转到允许我创建新配置Run As/Configurations
的Create, manage and run configurations
窗口,但服务器选择框不包含服务器。
I really have no idea whether that is what I need to be doing but I have tried so many options that I am now completely lost.
我真的不知道这是否是我需要做的,但我已经尝试了很多选择,现在我完全迷失了。
In the server window it says 'started, synchronised' by the server but it isn't even attempting to write files to the server directory (which is mounted on my file system).
在服务器窗口中,它说服务器“已启动,同步”,但它甚至没有尝试将文件写入服务器目录(安装在我的文件系统上)。
I am using 'Eclipse IDE for JavaScript Developers' v1.4.1, 'Eclipse Platform' v3.7.1.
我正在使用'Eclipse IDE for JavaScript Developers' v1.4.1,'Eclipse Platform' v3.7.1。
Could anyone point me in the right direction for publishing and running a simple JavaScript & HTML project on a local Virtual Machine?
谁能指出我在本地虚拟机上发布和运行一个简单的 JavaScript 和 HTML 项目的正确方向?
回答by Shaunak
Publishing Static Content and JavaScript on Apache Server using Eclipse
使用 Eclipse 在 Apache 服务器上发布静态内容和 JavaScript
Add Server
添加服务器
- Window -> Show View -> Servers
- Right click inside servers tab
- New - > Server -> HTTP Server -> Next
- add publishing dir: in my case (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs)
- Next -> add port (12345 in my case)
- 窗口 -> 显示视图 -> 服务器
- 在服务器选项卡内右键单击
- 新建 -> 服务器 -> HTTP 服务器 -> 下一步
- 添加发布目录:在我的情况下(C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs)
- 下一步 -> 添加端口(在我的例子中是 12345)
Create a web project
创建一个网络项目
- Switch to Web View (Right hand top corner)
- Right click Project Explorer in left
- New -> Project -> Web -> Static Web Project
- Name the Project
- Select Runtime Target as HTTP Server
- Next -> Notice your default context root
- Finish
- 切换到 Web 视图(右上角)
- 右键单击左侧的 Project Explorer
- 新建 -> 项目 -> Web -> 静态 Web 项目
- 命名项目
- 选择运行时目标作为 HTTP 服务器
- 下一步 -> 注意你的默认上下文根
- 结束
Copy your current js and html files in the 'WebContent' directory in Project Explorer.
将当前的 js 和 html 文件复制到 Project Explorer 的“WebContent”目录中。
In Servers Tab
在服务器选项卡中
- Right click HTTP Server
- Add - Remove -> Add your project -> Finish
- Right click Http Server -> Publish 4 done!
- 右键单击 HTTP 服务器
- 添加 - 删除 -> 添加您的项目 -> 完成
- 右键单击 Http Server -> 发布 4 完成!
You should be able to see your stuff in publishing directory. you can access the page at
您应该能够在发布目录中看到您的内容。您可以访问该页面
http://localhost:/context_root
http://localhost:/context_root
cheers!
干杯!
回答by sethupathi.t
Before going to run your web project, you should have any of the servers like Apache Tomcat, JBoss, etc.
在运行您的 Web 项目之前,您应该拥有任何服务器,例如 Apache Tomcat、JBoss 等。
1.Right click on your project - Run As - Run on Server
1.右键单击您的项目-运行方式-在服务器上运行
2.Consider currently there is no server configured into Eclipse, so you have to select the sever (consider you have Apache Tomcat server) and configured into Eclipse and click finish. The server will be starts automatically and the project will be running in Eclipse internal browser.
2.考虑到目前没有服务器配置到Eclipse中,所以你必须选择服务器(考虑你有Apache Tomcat服务器)并配置到Eclipse中,然后单击完成。服务器将自动启动,项目将在 Eclipse 内部浏览器中运行。
3.If suppose server is not started - right click on the server - in the below server tab - select start option.
3.如果假设服务器没有启动 - 右键单击服务器 - 在下面的服务器选项卡中 - 选择启动选项。
4.There is a chance to fail the server start - the configured port in the server may be used by other server, so you need to change the server port - right click the configured server and click open - change the HTTP port 8080 to some other port.
4.有可能导致服务器启动失败——服务器中配置的端口可能被其他服务器使用,因此需要更改服务器端口——右键单击配置的服务器并单击打开——将HTTP端口8080更改为一些其他港口。
5.Start the server
5.启动服务器
6.There is an option to check whether your project is deployed successfully in the server or not. Right click configured server and click Add and Remove option - There will be showing available web project and deployed web project.
6.有一个选项可以检查您的项目是否在服务器中部署成功。右键单击已配置的服务器,然后单击添加和删除选项 - 将显示可用的 Web 项目和已部署的 Web 项目。
回答by Francis Upton IV
I tried this and was able to get it to work by doing this:
我试过这个并且能够通过这样做来让它工作:
1) Delete the server you have in the Servers tab. Also go into the Preferences -> Servers -> Runtime Environment and make sure you have your server set up the way you want. If you are using a real web server for example, use an HTTP Server and specify the port, and the path of where to publish to (this is where it will write your stuff to).
1) 删除您在“服务器”选项卡中拥有的服务器。还要进入 Preferences -> Servers -> Runtime Environment 并确保您的服务器设置为您想要的方式。例如,如果您使用的是真正的 Web 服务器,请使用 HTTP 服务器并指定端口和发布到的路径(这是它将写入您的内容的位置)。
2) Create a new server by right-clicking in the Servers tab. This will have you select the server you created (or used) in the Preferences (above) and then it will let you select the projects in your workspace to associated with the server.
2) 通过右键单击“服务器”选项卡来创建新服务器。这将使您在首选项(上方)中选择您创建(或使用)的服务器,然后您可以选择工作区中与服务器关联的项目。
3) Right click the server and select "publish", and you will see your artifacts in the directory that you selected for your server. You should now be able to access them with the server.
3) 右键单击服务器并选择“发布”,您将在为服务器选择的目录中看到您的工件。您现在应该可以使用服务器访问它们。
(It's not that easy to figure this out when you first get started, so I understand your frustration).
(当您刚开始时要弄清楚这一点并不容易,所以我理解您的沮丧)。