开发者

Setting up Jetty in Eclipse [duplicate]

This question already has answers here: 开发者_如何学运维 Running jetty from eclipse (3 answers) Closed 9 years ago.

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?

Thanks

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


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).


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:

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();
}


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 .

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

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


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

<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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜