你能直接从 eclipse 发布一个 .war 到 web 服务器吗
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2407151/
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
Can you publish a .war directly from eclipse to a web server
提问by Ankur
Can you publish a .war directly from eclipse to a web server.
你能直接从 eclipse 发布一个 .war 到 web 服务器吗?
I know it's not a programming question, but I still think it's a relevant question.
我知道这不是一个编程问题,但我仍然认为这是一个相关的问题。
Thanks
谢谢
回答by GuruKulki
yes you can.
是的你可以。
right click on the project, select export -> select web - > then war and give destination which is your deploy folder.
右键单击项目,选择导出 -> 选择 web -> 然后 war 并给出目标,即您的部署文件夹。
回答by Padmarag
Yes, but it depends a lot on your project configuration. Generally you need to define the server in eclipse, and choose "Run on Server".
是的,但这在很大程度上取决于您的项目配置。一般需要在eclipse中定义服务器,选择“Run on Server”。
See thisas an example of deploying on JBoss server from eclipse.
In case you are using Ant then using "deploy" target will work.
看到这从蚀部署JBoss服务器上的一个例子。
如果您使用 Ant,那么使用“deploy”目标将起作用。
回答by Rahul
If your project is setup as a web project in Eclipse, you can choose to run it on a server (You'll have to configure the server first). This will publish the war file directly on the server from Eclipse.
如果您的项目在 Eclipse 中设置为 Web 项目,您可以选择在服务器上运行它(您必须先配置服务器)。这将从 Eclipse 直接在服务器上发布 war 文件。
回答by Thorbj?rn Ravn Andersen
This is easiest if the web server has an auto-deploy facility, with a magic directory. Then just File-> Export the WAR file into the auto-deploy folder.
如果 Web 服务器具有自动部署工具和魔法目录,这将是最简单的。然后只需文件-> 将 WAR 文件导出到自动部署文件夹中。
If not, or if you want to be able to debug the WAR file inside Eclipse you need to have an appropriate server connector in the WTP module (which is included by default in the Java EE edition of Eclipse).
如果没有,或者如果您希望能够在 Eclipse 中调试 WAR 文件,您需要在 WTP 模块(默认情况下包含在 Eclipse 的 Java EE 版本中)中有一个合适的服务器连接器。
If you want to programmatically push the WAR file to a given server directly from within Eclipse, then you can e.g. use the Tomcat Ant tasks - http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant- or use the Cargo library to do this with many different types of servers - http://cargo.codehaus.org/
如果您想直接从 Eclipse 中以编程方式将 WAR 文件推送到给定服务器,那么您可以使用 Tomcat Ant 任务 - http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#执行 %20Manager%20Commands%20With%20Ant- 或使用 Cargo 库对许多不同类型的服务器执行此操作 - http://cargo.codehaus.org/
回答by Russell
This should be pretty easy:
这应该很简单:
Import the war file into eclipse. File > Import... > Web > WAR File. (likely only works on eclipse for java ee development)
Pick the war file, create a new project (any new name works), click finish
Add the new project to your server
Blam!
将war文件导入eclipse。文件 > 导入... > Web > WAR 文件。(可能只适用于 java ee 开发的 eclipse)
选择war文件,创建一个新项目(任何新名称都可以),点击完成
将新项目添加到您的服务器
该死!
回答by nos
I created my own ant file, and set eclipse to use that ant file when building. Part of that ant build file is a target that publishes to Tomcat, so I can just right click and chose install from within eclipse.
我创建了自己的 ant 文件,并在构建时将 eclipse 设置为使用该 ant 文件。该 ant 构建文件的一部分是发布到 Tomcat 的目标,因此我只需右键单击并从 eclipse 中选择安装。
Eclipse pic http://img408.imageshack.us/img408/6701/eclipseant.png
日食图片 http://img408.imageshack.us/img408/6701/eclipseant.png
The basis of such an ant file is here: http://tomcat.apache.org/tomcat-6.0-doc/appdev/build.xml.txt
这样一个ant文件的基础在这里:http: //tomcat.apache.org/tomcat-6.0-doc/appdev/build.xml.txt
回答by gmhk
Yes, you do that
是的,你这样做
- Start the build the application
- Create the war file A WAR (or "web archive") file is simply a packaged webapp directory. It is created using the standard Java jar tool. For example:
- 开始构建应用程序
- 创建 war 文件 WAR(或“Web 存档”)文件只是一个打包的 webapp 目录。它是使用标准 Java jar 工具创建的。例如:
cd /home/alex/webapps/mywebapp jar cf ../mywebapp.war * - copy that war file to the following deploy directory in your server say in Jboss its like this "C:\Jboss405\server\default\deploy"
cd /home/alex/webapps/mywebapp jar cf ../mywebapp.war * - 将该 war 文件复制到服务器中的以下部署目录,在 Jboss 中说它像这样“ C:\Jboss405\server\default\deploy”
I hope this might be clear, else let me know any issues if you face any issues
我希望这可能很清楚,否则如果您遇到任何问题,请告诉我任何问题