在 Eclipse 中设置 Jetty

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4180873/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:20:47  来源:igfitidea点击:

Setting up Jetty in Eclipse

eclipsejettytapestry

提问by JPC

I'm trying to follow a tutorial on Tapestry. (http://tapestry.apache.org/tapestry5.1/tutorial1/env.html) The tutorial recommends Jetty 5.1 so I can use a plugin called JettyLauncher to run Jetty applications from inside Eclipse. Right now though, Jetty is at version 7 I believe. I don't want to start with an out of date web server. Does Jetty 7 have any eclipse plugins similar to what I imagine Jetty 5.1 + Jetty Launcher is supposed to do?

我正在尝试学习有关 Tapestry 的教程。(http://tapestry.apache.org/tapestry5.1/tutorial1/env.html) 本教程推荐使用 Jetty 5.1,因此我可以使用名为 JettyLauncher 的插件从 Eclipse 内部运行 Jetty 应用程序。不过现在,我相信 Jetty 是第 7 版。我不想从过时的 Web 服务器开始。Jetty 7 是否有任何 eclipse 插件类似于我想象的 Jetty 5.1 + Jetty Launcher 应该做的?

Thanks

谢谢

EDIT: I'm trying Run Jetty Run and m2eclipse. We'll see how this works

编辑:我正在尝试运行 Jetty Run 和 m2eclipse。我们将看看这是如何工作的

采纳答案by pbanfi

you can go to window -> preferences -> server -> runtime environments and choose to add a new server environment. in th efollowing dialog you can download the "additional server adapters". ther you can chose the Jetti adapter. This way you can configure and use jetty as stated in the WTP documentation (i.e you can configure a new jetty instance in the server view and start stop synch it from there).

您可以转到窗口 -> 首选项 -> 服务器 -> 运行时环境并选择添加新的服务器环境。在下面的对话框中,您可以下载“附加服务器适配器”。您可以选择 Jetti 适配器。这样您就可以按照 WTP 文档中的说明配置和使用 jetty(即您可以在服务器视图中配置一个新的 jetty 实例并从那里开始停止同步)。

回答by Thiago H. de Paula Figueiredo

Running Jetty through the m2eclipse (jetty:run) works very well. On the other hand, my preferred way of using Jetty is starting in embedded mode (i.e. launching it programatically). This snippet works for Jetty 6, including debugging. I haven't tested it in Jetty 7, but I guess it can be easily adapted for 7:

通过 m2eclipse (jetty:run) 运行 Jetty 效果很好。另一方面,我使用 Jetty 的首选方式是以嵌入模式启动(即以编程方式启动它)。此代码段适用于 Jetty 6,包括调试。我还没有在 Jetty 7 中测试过它,但我想它可以很容易地适应 7:

Server server = new Server(8080);

WebAppContext webapp = new WebAppContext();
webapp.setParentLoaderPriority(true);
webapp.setContextPath("/");
webapp.setWar("src/main/webapp");
server.setHandler(webapp);
try {
    server.start();
    server.join();
}
catch (Exception e) {
    e.printStackTrace();
}

回答by TonyQ

As a developer of Run-Jetty-Run , I strongly suggest to use Run-Jetty-Run plugin , if you meet any question ,please feel free to post issues .

作为 Run-Jetty-Run 的开发者,我强烈建议使用 Run-Jetty-Run 插件,如果您遇到任何问题,请随时发布问题。

http://code.google.com/p/run-jetty-run/issues/list

http://code.google.com/p/run-jetty-run/issues/list

I will try to take a look as possible as I could.

我会尽量看一看。

回答by Gillespie59

Or you can use Maven! add the Jetty plugin in the pom.xml!

或者你可以使用 Maven!在 pom.xml 中添加 Jetty 插件!

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <version>6.1.9</version>
  <configuration>
    <requestLog implementation="org.mortbay.jetty.NCSARequestLog">
      <append>true</append>
    </requestLog>
  </configuration>
</plugin>

And in the Run Configurations Window, add an entry to Maven Build ! You just have - to choose a name for your new command - to choose your project - in the goals, write -Djetty.port=8900 jetty:run

在 Run Configurations 窗口中,向 Maven Build 添加一个条目!你只需要 - 为你的新命令选择一个名字 - 选择你的项目 - 在目标中,写 -Djetty.port=8900 jetty:run

So, when you run with this command, your application will be available at this address : http://localhost:8900

因此,当您使用此命令运行时,您的应用程序将在以下地址可用:http://localhost:8900