修改pom.xml
创建Maven Java工程并且修改pom.xml
<dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>3.1.4.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxb-provider</artifactId> <version>3.1.4.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-servlet-initializer</artifactId> <version>3.1.4.Final</version> </dependency>
定义Application
package com.inforstack.resteasy.api;
import javax.ws.rs.ApplicationPath;
@ApplicationPath(value = "/api")
public class Application extends javax.ws.rs.core.Application {
}
定义controller
package com.inforstack.resteasy.api;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/demo")
public class DemoService {
@GET
@Path("/list")
public String getBooks() {
return "demo";
}
}
PS:使用的Servlet需要版本3.0以上
启动tomcat之后打开浏览器输入:http://localhost:8080/resteasy/api/demo/list

本文暂时没有评论,来添加一个吧(●'◡'●)