如何在eclipse下在glassfish上部署REST服务?
我编写了一个简单的 REST 服务类,我需要在安装在 Eclipse 上的 glassfish 服务器下部署并运行它。
我需要执行哪些步骤才能将此 Restlet 服务上线并通过浏览器访问它?
这是代码:
import javax.ws.rs.*;
import javax.ws.rs.core.*;
@Path("/myApplication")
public class MailRestlet {
@SuppressWarnings("unused")
@Context
private UriInfo context;
/**
* Default constructor.
*/
public MyRestlet() {
// TODO Auto-generated constructor stub
}
@GET
@Produces("text/html")
public String getHtml() {
return "<html><body><h1>Hello World!!</h1>The service is online!!</body></html>";
}
}
I've written a simple REST service class, and I need to deploy and run it under glassfish server, installed on my eclipse.
What steps have I to do in order to put this restlet service online and reach it from my browser?
This is the code:
import javax.ws.rs.*;
import javax.ws.rs.core.*;
@Path("/myApplication")
public class MailRestlet {
@SuppressWarnings("unused")
@Context
private UriInfo context;
/**
* Default constructor.
*/
public MyRestlet() {
// TODO Auto-generated constructor stub
}
@GET
@Produces("text/html")
public String getHtml() {
return "<html><body><h1>Hello World!!</h1>The service is online!!</body></html>";
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还需要配置 web.XML 文件,例如,如 http://download.oracle.com/docs/cd/E19776-01/820-4867/ggrby/index.html
还有一种方法可以避免 web.XML 更改,通过扩展来自 jaxrs 的应用程序类...
You also need to configure the web.XML file, for example, as in http://download.oracle.com/docs/cd/E19776-01/820-4867/ggrby/index.html
There is also a way to avoid web.XML change, by extending the Application class from jaxrs...
作为使用 web.xml 文件配置端点的替代方法,您可以按如下所述扩展 Application 类 此处。
在 Eclipse 中,您可以通过以下方式在服务器上部署:
As an alternative to configuring the end point using the web.xml file, you can extend the Application class as described here.
From in Eclipse, you can deploy on the server by: