RestEasy 配置

1.项目使用seam框架的话,只需引入
<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>jaxrs-api</artifactId>
			<version>2.0.1.GA</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.jboss.seam</groupId>
			<artifactId>jboss-seam-resteasy</artifactId>
			<version>2.2.0.GA</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-jaxrs</artifactId>
			<version>2.0.1.GA</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
这三个依赖即可,在web.xml 配置
<servlet>
		<servlet-name>Seam Resource Servlet</servlet-name>
		<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
<servlet-mapping>
		<servlet-name>Seam Resource Servlet</servlet-name>
		<url-pattern>/seam/resource/*</url-pattern>
	</servlet-mapping>
	</servlet>


2.非seam应用,要配置一个监听器
<listener>
		<listener-class>
			org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
		</listener-class>
	</listener>
	<servlet>
		<servlet-name>Resteasy</servlet-name>
		<servlet-class>
			org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
		</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>Resteasy</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>

还需要配置
<context-param>
       <param-name>resteasy.scan</param-name>
       <param-value>true</param-value>
  </context-param>
自动扫描 WEB-INF/lib 目录下的jar文件和 WEB-INF/classes 目录下标识了 @Provider 和 JAX-RS 注解(@Path, @GET, @POST etc..) 的类资源文件,并且注册它们。

你可能感兴趣的:(resteasy,seam)