spring easyrest first

 

构建 多module 多pom 项目详解:

http://knight-black-bob.iteye.com/blog/2361377

 demo 下载

 http://download.csdn.net/download/knight_black_bob/9796647

 

 

构建一个 easyrest 项目

该项目为 多pom项目

 

 

 

1.pom文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.curiousby.cn</groupId>
	<artifactId>SpringRestDemo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>pom</packaging>

	<name>SpringRestDemo</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<spring.version>4.3.2.RELEASE</spring.version>
		<org.slf4j-version>1.7.9</org.slf4j-version>
		<org.logback-version>1.0.1</org.logback-version>
		<janino-version>2.5.10</janino-version>
		<mysql.jdbc.version>5.1.30</mysql.jdbc.version>
		<ebean-version>2.8.1</ebean-version>
		<thymeleaf-version>2.1.2.RELEASE</thymeleaf-version>
		<resteasy.version>3.0.19.Final</resteasy.version>
		<spring-data-redis-version>1.3.2.RELEASE</spring-data-redis-version>
		<jedis-version>2.4.2</jedis-version>
		<activemq-version>5.9.0</activemq-version>
		<activemq.version>5.14.1</activemq.version>
		<dubbo.version>2.5.3</dubbo.version>
	</properties>

	<modules>
		<module>com.curiousby.cn.entity</module>
		<module>com.curiousby.cn.service</module>
		<module>com.curiousby.cn.serviceImpl</module>
		<module>com.curiousby.cn.rest</module>
		<module>com.curiousby.cn.restImpl</module>
		<module>com.curiousby.cn.redis</module>
	</modules>





	<dependencies>

		<!-- junit4 start -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.7</version>
			<type>jar</type>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.dbunit</groupId>
			<artifactId>dbunit</artifactId>
			<version>2.4.9</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.github.springtestdbunit</groupId>
			<artifactId>spring-test-dbunit</artifactId>
			<version>1.1.0</version>
			<scope>test</scope>
		</dependency>
		<!-- junit4 end -->
	</dependencies>


	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.curiousby.cn.entity</groupId>
				<artifactId>com.curiousby.cn.entity</artifactId>
				<version>${project.version}</version>
			</dependency>
			<dependency>
				<groupId>com.curiousby.cn.service</groupId>
				<artifactId>com.curiousby.cn.service</artifactId>
				<version>${project.version}</version>
			</dependency>
			<dependency>
				<groupId>com.curiousby.cn.serviceImpl</groupId>
				<artifactId>com.curiousby.cn.serviceImpl</artifactId>
				<version>${project.version}</version>
			</dependency>
			<dependency>
				<groupId>com.curiousby.cn.rest</groupId>
				<artifactId>com.curiousby.cn.rest</artifactId>
				<version>${project.version}</version>
			</dependency>
			<dependency>
				<groupId>com.curiousby.cn.restImpl</groupId>
				<artifactId>com.curiousby.cn.restImpl</artifactId>
				<version>${project.version}</version>
			</dependency>
			<dependency>
				<groupId>com.curiousby.cn.redis</groupId>
				<artifactId>com.curiousby.cn.redis</artifactId>
				<version>${project.version}</version>
			</dependency>

			<!-- logging slf4j start -->
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-api</artifactId>
				<version>1.6.4</version>
				<type>jar</type>
			</dependency>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-log4j12</artifactId>
				<version>1.6.4</version>
				<type>jar</type>
			</dependency>



			<!-- resteasy start -->
			<dependency>
				<groupId>org.jboss.resteasy</groupId>
				<artifactId>resteasy-cache-core</artifactId>
				<version>${resteasy.version}</version>
			</dependency>
			<dependency>
				<groupId>org.jboss.resteasy</groupId>
				<artifactId>resteasy-validator-provider-11</artifactId>
				<version>${resteasy.version}</version>
			</dependency>
			<dependency>
				<groupId>org.jboss.resteasy</groupId>
				<artifactId>resteasy-jackson2-provider</artifactId>
				<version>${resteasy.version}</version>
			</dependency>
			<dependency>
				<groupId>org.jboss.resteasy</groupId>
				<artifactId>resteasy-jaxb-provider</artifactId>
				<version>${resteasy.version}</version>
			</dependency>
			<dependency>
				<groupId>org.jboss.resteasy</groupId>
				<artifactId>resteasy-spring</artifactId>
				<version>${resteasy.version}</version>
				<exclusions>
					<exclusion>
						<groupId>commons-httpclient</groupId>
						<artifactId>commons-httpclient</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.jboss.resteasy</groupId>
						<artifactId>resteasy-jettison-provider</artifactId>
					</exclusion>
				</exclusions>
			</dependency>
			<dependency>
				<groupId>org.apache.geronimo.specs</groupId>
				<artifactId>geronimo-servlet_3.0_spec</artifactId>
				<version>1.0</version>
				<scope>provided</scope>
			</dependency>

			<dependency>
				<groupId>org.apache.geronimo.specs</groupId>
				<artifactId>geronimo-jsp_2.1_spec</artifactId>
				<version>1.0.1</version>
				<scope>provided</scope>
			</dependency>
			<dependency>
				<groupId>org.jboss.resteasy</groupId>
				<artifactId>resteasy-servlet-initializer</artifactId>
				<version>${resteasy.version}</version>
			</dependency>
			<!-- resteasy end -->

			<!-- spring jar start -->
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-orm</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-tx</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context-support</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-webmvc</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-web</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-jms</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aop</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-oxm</artifactId>
				<version>${spring.version}</version>
			</dependency>

			<dependency>
				<groupId>org.springframework.kafka</groupId>
				<artifactId>spring-kafka</artifactId>
				<version>1.1.0.RELEASE</version>
			</dependency>

			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-aspects</artifactId>
				<version>${spring.version}</version>
			</dependency>
			<!-- spring jar end -->

			<!-- spring security start -->
			<dependency>
				<groupId>org.springframework.security</groupId>
				<artifactId>spring-security-config</artifactId>
				<version>4.0.3.RELEASE</version>
			</dependency>

			<dependency>
				<groupId>org.springframework.security</groupId>
				<artifactId>spring-security-core</artifactId>
				<version>4.0.3.RELEASE</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.security</groupId>
				<artifactId>spring-security-web</artifactId>
				<version>4.0.3.RELEASE</version>
			</dependency>
			<!-- spring security end -->

			<!-- quartz start -->
			<dependency>
				<groupId>org.quartz-scheduler</groupId>
				<artifactId>quartz</artifactId>
				<version>2.2.1</version>
			</dependency>
			<!-- quartz end -->

			<!-- json start -->
			<dependency>
				<groupId>org.codehaus.jackson</groupId>
				<artifactId>jackson-mapper-asl</artifactId>
				<version>1.9.13</version>
			</dependency>
			<dependency>
				<groupId>org.json</groupId>
				<artifactId>json</artifactId>
				<version>20160810</version>
			</dependency>
			<dependency>
				<groupId>com.fasterxml.jackson.core</groupId>
				<artifactId>jackson-annotations</artifactId>
				<version>2.6.4</version>
			</dependency>
			<dependency>
				<groupId>com.fasterxml.jackson.core</groupId>
				<artifactId>jackson-databind</artifactId>
				<version>2.6.4</version>
			</dependency>
			<dependency>
				<groupId>com.alibaba</groupId>
				<artifactId>fastjson</artifactId>
				<version>1.2.8</version>
			</dependency>
			<dependency>
				<groupId>net.sf.json-lib</groupId>
				<artifactId>json-lib</artifactId>
				<version>2.4</version>
				<classifier>jdk15</classifier>
			</dependency>
			<dependency>
				<groupId>net.sf.json-lib</groupId>
				<artifactId>json-lib-ext-spring</artifactId>
				<version>1.0.2</version>
			</dependency>
			<!-- json end -->

			<!-- mybatis start -->
			<dependency>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis</artifactId>
				<version>3.3.0</version>
			</dependency>
			<dependency>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis-spring</artifactId>
				<version>1.2.3</version>
			</dependency>
			<!-- mybatis start -->

			<!-- shardbatis start -->
			<dependency>
				<groupId>shardbatis</groupId>
				<artifactId>shardbatis</artifactId>
				<version>2.0</version>
			</dependency>
			<!-- shardbatis end -->

			<!-- pagehelper start -->
			<dependency>
				<groupId>com.github.pagehelper</groupId>
				<artifactId>pagehelper</artifactId>
				<version>4.1.3</version>
			</dependency>
			<!-- pagehelper end -->

			<!-- fastdfs start -->
			<dependency>
				<groupId>org.csource</groupId>
				<artifactId>fastdfs-client-java</artifactId>
				<version>1.25</version>
			</dependency>
			<!-- fastdfs end -->

			<!-- poi start -->
			<dependency>
				<groupId>org.apache.poi</groupId>
				<artifactId>poi-ooxml</artifactId>
				<version>3.9</version>
			</dependency>
			<!-- poi end -->

			<!-- redis start -->
			<dependency>
				<groupId>org.springframework.data</groupId>
				<artifactId>spring-data-redis</artifactId>
				<version>1.7.2.RELEASE</version>
			</dependency>

			<dependency>
				<groupId>redis.clients</groupId>
				<artifactId>jedis</artifactId>
				<version>2.4.2</version>
			</dependency>
			<!-- redis end -->


			<!-- mysql start -->
			<dependency>
				<groupId>mysql</groupId>
				<artifactId>mysql-connector-java</artifactId>
				<version>5.1.18</version>
				<type>jar</type>
				<scope>compile</scope>
			</dependency>
			<!-- mysql end -->

			<!-- sql pool start -->
			<dependency>
				<groupId>com.alibaba</groupId>
				<artifactId>druid</artifactId>
				<version>1.0.16</version>
			</dependency>
			<!-- sql pool end -->


			<!-- commons start -->
			<dependency>
				<groupId>commons-beanutils</groupId>
				<artifactId>commons-beanutils-core</artifactId>
				<version>1.8.3</version>
				<type>jar</type>
				<scope>compile</scope>
			</dependency>
			<dependency>
				<groupId>commons-beanutils</groupId>
				<artifactId>commons-beanutils-bean-collections</artifactId>
				<version>1.8.3</version>
				<type>jar</type>
				<scope>compile</scope>
			</dependency>
			<dependency>
				<groupId>commons-io</groupId>
				<artifactId>commons-io</artifactId>
				<version>2.4</version>
				<type>jar</type>
				<scope>compile</scope>
			</dependency>
			<dependency>
				<groupId>commons-logging</groupId>
				<artifactId>commons-logging</artifactId>
				<version>1.1.1</version>
				<type>jar</type>
				<scope>compile</scope>
			</dependency>
			<dependency>
				<groupId>commons-fileupload</groupId>
				<artifactId>commons-fileupload</artifactId>
				<version>1.3.1</version>
				<type>jar</type>
				<scope>compile</scope>
			</dependency>
			<dependency>
				<groupId>commons-pool</groupId>
				<artifactId>commons-pool</artifactId>
				<version>1.6</version>
				<type>jar</type>
				<scope>compile</scope>
				<optional>false</optional>
			</dependency>
			<dependency>
				<groupId>commons-collections</groupId>
				<artifactId>commons-collections</artifactId>
				<version>3.2.1</version>
				<type>jar</type>
				<scope>compile</scope>
				<optional>false</optional>
			</dependency>
			<dependency>
				<groupId>org.apache.commons</groupId>
				<artifactId>commons-email</artifactId>
				<version>1.3.2</version>
			</dependency>
			<!-- commons end -->



			<!--jsp start -->
			<dependency>
				<groupId>taglibs</groupId>
				<artifactId>standard</artifactId>
				<version>1.1.2</version>
			</dependency>
			<dependency>
				<groupId>jstl</groupId>
				<artifactId>jstl</artifactId>
				<version>1.2</version>
			</dependency>
			<!--jsp end -->

			<dependency>
				<groupId>org.aspectj</groupId>
				<artifactId>aspectjweaver</artifactId>
				<version>1.8.9</version>
			</dependency>
			<dependency>
				<groupId>org.aspectj</groupId>
				<artifactId>aspectjrt</artifactId>
				<version>1.7.2</version>
			</dependency>



		</dependencies>
	</dependencyManagement>

	<build>
		<plugins>
<!-- 
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.3</version>
				<dependencies>
					<dependency>
						<groupId>org.codehaus.plexus</groupId>
						<artifactId>plexus-compiler-javac</artifactId>
						<version>2.5</version>
					</dependency>
				</dependencies>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
					<encoding>UTF-8</encoding>
					<compilerArguments>
						<verbose />
						<bootclasspath>${java.home}/lib/rt.jar:${java.home}/lib/jce.jar</bootclasspath>
					</compilerArguments>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<version>2.5.1</version>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.9.1</version>
				<configuration>
					<encoding>UTF-8</encoding>
					<outputEncoding>UTF-8</outputEncoding>
				</configuration>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.8</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
 -->
			<plugin>
				<!-- MAVEN 编译使用的JDK版本 -->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.3</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.4.2</version>
				<configuration>
					<skipTests>false</skipTests>
					<testFailureIgnore>true</testFailureIgnore>
					<argLine>${argLine}</argLine>
				</configuration>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.eclipse.jetty</groupId>
					<artifactId>jetty-maven-plugin</artifactId>
					<version>9.2.8.v20150217</version>
				</plugin>
				<plugin>
					<groupId>org.mortbay.jetty</groupId>
					<artifactId>jetty-maven-plugin</artifactId>
					<version>7.1.6.v20100715</version>
				</plugin>
			</plugins> 
			</pluginManagement>
			<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
		</resources>
	</build>
</project>

 

2. rest 接口

/*
 * Project: com.curiousby.cn.rest
 * 
 * File Created at 2017年3月6日
 * 
 * Copyright 2016 CMCC Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * curiousby Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license.
 */
package com.curiousby.cn.rest;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.springframework.stereotype.Controller;

import com.curiousby.cn.entity.User;
import com.curiousby.cn.resp.CommonResp;

/**
 * @Type UserRest.java
 * @Desc 
 * @author baoyou [email protected]
 * @date 2017年3月6日 下午4:09:47
 * @version 
 */
@Controller
@Produces({MediaType.APPLICATION_JSON})
@Path("/user")
public interface UserRest {

    @GET 
    @Path("one/{id}")
    public CommonResp findById(@QueryParam("id") Integer  id);

    @GET 
    @Path("/list")
    public CommonResp findAll();

}

/**
 * Revision history
 * -------------------------------------------------------------------------
 * 
 * Date Author Note
 * -------------------------------------------------------------------------
 * 2017年3月6日 baoyou [email protected] creat
 */

 

<?xml version="1.0"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.curiousby.cn</groupId>
		<artifactId>SpringRestDemo</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<groupId>com.curiousby.cn.rest</groupId>
	<artifactId>com.curiousby.cn.rest</artifactId>
	<name>com.curiousby.cn.rest</name>
	<url>http://maven.apache.org</url>
	<packaging>jar</packaging>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencies>
		<dependency>
			<groupId>com.curiousby.cn.entity</groupId>
			<artifactId>com.curiousby.cn.entity</artifactId>
		</dependency>

		<!-- spring start -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</dependency>
		<!-- spring end -->
		
		<!-- resteasy start -->
		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-jackson2-provider</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-jaxb-provider</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.jboss.spec.javax.ws.rs</groupId>
					<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
				</exclusion>
			</exclusions>

		</dependency>
		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-spring</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.geronimo.specs</groupId>
			<artifactId>geronimo-servlet_3.0_spec</artifactId>
			<scope>provided</scope>
		</dependency>
		<!-- resteasy end -->
	</dependencies>
</project>

 

3.restimpl 实现

/*
 * Project: com.curiousby.cn.restImpl
 * 
 * File Created at 2017年3月6日
 * 
 * Copyright 2016 CMCC Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * curiousby Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license.
 */
package com.curiousby.cn.restImpl;
 
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import com.curiousby.cn.RespEnumStates;
import com.curiousby.cn.entity.User;
import com.curiousby.cn.resp.CommonResp;
import com.curiousby.cn.rest.UserRest;

/**
 * @Type UserRestImpl.java
 * @Desc 
 * @author baoyou [email protected]
 * @date 2017年3月6日 下午4:15:31
 * @version 
 */
@Component
public class UserRestImpl implements UserRest{

    public CommonResp findById(Integer id) {  
        return  new CommonResp(new User(1,"1","1")).setCode(RespEnumStates.RESP_SUCCESS.getType()).setMsg("success");
    }

    public CommonResp findAll() {  
        List<User> list = new ArrayList<User>();
        list.add(new User(1,"1","1"));
        return    new CommonResp(list).setCode(RespEnumStates.RESP_SUCCESS.getType()).setMsg("success");
    }

}


/**
 * Revision history
 * -------------------------------------------------------------------------
 * 
 * Date Author Note
 * -------------------------------------------------------------------------
 * 2017年3月6日 baoyou [email protected] creat
 */

 

 

<?xml version="1.0"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.curiousby.cn</groupId>
		<artifactId>SpringRestDemo</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<groupId>com.curiousby.cn.restImpl</groupId>
	<artifactId>com.curiousby.cn.restImpl</artifactId>
	<name>com.curiousby.cn.restImpl</name>
	<url>http://maven.apache.org</url>
	<packaging>war</packaging>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencies>
		<dependency>
			<groupId>com.curiousby.cn.entity</groupId>
			<artifactId>com.curiousby.cn.entity</artifactId>
		</dependency>
		<dependency>
			<groupId>com.curiousby.cn.rest</groupId>
			<artifactId>com.curiousby.cn.rest</artifactId>
		</dependency> 
		
		
	</dependencies>

	<build>
		<finalName>rest</finalName>
		<plugins>
			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<configuration>
					<webAppConfig>
						<contextPath>/rest</contextPath>
					</webAppConfig>
					<connectors>
						<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
							<port>8084</port>
							<maxIdleTime>60000</maxIdleTime>
						</connector>
					</connectors>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	metadata-complete="true">

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>
	<context-param>
		<param-name>resteasy.servlet.mapping.prefix</param-name>
		<param-value>/rest</param-value>
	</context-param>

	<context-param>
		<param-name>resteasy.media.type.mappings</param-name>
		<param-value>json : application/json, xml : application/xml</param-value>
	</context-param>

	<!-- Start Resteasy   -->
	<listener>
	    <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
	</listener>
	<!-- load Spring Context  -->
	<listener>
	    <listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</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>/rest/*</url-pattern>
	</servlet-mapping>
	
	
	
	 <filter>
        <filter-name>encoding-filter</filter-name>
        <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
     <filter-mapping>
        <filter-name>encoding-filter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>  

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:redis="http://www.springframework.org/schema/redis"
	xsi:schemaLocation="http://www.springframework.org/schema/beans   
    http://www.springframework.org/schema/beans/spring-beans.xsd  
    http://www.springframework.org/schema/context  
    http://www.springframework.org/schema/context/spring-context.xsd  
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd  
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
	
	
	
	<context:component-scan base-package="com.curiousby.cn"></context:component-scan>
	 
</beans>

 

 

4.测试


spring easyrest first_第1张图片
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

捐助开发者

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。



 
 
 谢谢您的赞助,我会做的更好!

 

 

你可能感兴趣的:(spring,first,easyrest)