spring easyrest first

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介:   构建 多module 多pom 项目详解: http://knight-black-bob.iteye.com/blog/2361377  demo 下载  http://download.

 

构建 多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 curiousby@163.com
 * @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 curiousby@163.com 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 curiousby@163.com
 * @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 curiousby@163.com 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.测试



 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

捐助开发者

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



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

 

 

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore &nbsp; &nbsp; ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库&nbsp;ECS 实例和一台目标数据库&nbsp;RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&amp;RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
编解码 前端开发 Java
spring cloud discovery bootstrap first 非对称加密坑
2017-04-16 00:18:17.613 INFO [water-cloud-provider-uac,,,] [water-cloud-provider-uac,,,,] 9096 --- [ main] s.
1245 0
|
XML Java 数据库
springmvc+spring+mybatis整合案例 [first]
本次总结一个出门级别的ssm整合案例(只介绍查询操作 具体其他操作可以自己自由实现) 注意事项: 1.本案例使用intellij idea开发 2.具体jar包不做介绍(本人导入了spring的全部包+mybatis的包以及数据库驱动包和pring-mybatis整合工具包) 3.本案例很大程度上参考了一些教学视频(如有侵权,请给我留言) 4.本案例只供学习使用.
1505 0
|
4天前
|
XML Java 应用服务中间件
Spring Boot 两种部署到服务器的方式
本文介绍了Spring Boot项目的两种部署方式:jar包和war包。Jar包方式使用内置Tomcat,只需配置JDK 1.8及以上环境,通过`nohup java -jar`命令后台运行,并开放服务器端口即可访问。War包则需将项目打包后放入外部Tomcat的webapps目录,修改启动类继承`SpringBootServletInitializer`并调整pom.xml中的打包类型为war,最后启动Tomcat访问应用。两者各有优劣,jar包更简单便捷,而war包适合传统部署场景。需要注意的是,war包部署时,内置Tomcat的端口配置不会生效。
92 17
Spring Boot 两种部署到服务器的方式
|
4天前
|
Dart 前端开发 JavaScript
springboot自动配置原理
Spring Boot 自动配置原理:通过 `@EnableAutoConfiguration` 开启自动配置,扫描 `META-INF/spring.factories` 下的配置类,省去手动编写配置文件。使用 `@ConditionalXXX` 注解判断配置类是否生效,导入对应的 starter 后自动配置生效。通过 `@EnableConfigurationProperties` 加载配置属性,默认值与配置文件中的值结合使用。总结来说,Spring Boot 通过这些机制简化了开发配置流程,提升了开发效率。
38 17
springboot自动配置原理
|
3月前
|
人工智能 自然语言处理 前端开发
SpringBoot + 通义千问 + 自定义React组件:支持EventStream数据解析的技术实践
【10月更文挑战第7天】在现代Web开发中,集成多种技术栈以实现复杂的功能需求已成为常态。本文将详细介绍如何使用SpringBoot作为后端框架,结合阿里巴巴的通义千问(一个强大的自然语言处理服务),并通过自定义React组件来支持服务器发送事件(SSE, Server-Sent Events)的EventStream数据解析。这一组合不仅能够实现高效的实时通信,还能利用AI技术提升用户体验。
303 2
|
9天前
|
XML JavaScript Java
SpringBoot集成Shiro权限+Jwt认证
本文主要描述如何快速基于SpringBoot 2.5.X版本集成Shiro+JWT框架,让大家快速实现无状态登陆和接口权限认证主体框架,具体业务细节未实现,大家按照实际项目补充。
58 11
|
12天前
|
缓存 安全 Java
Spring Boot 3 集成 Spring Security + JWT
本文详细介绍了如何使用Spring Boot 3和Spring Security集成JWT,实现前后端分离的安全认证概述了从入门到引入数据库,再到使用JWT的完整流程。列举了项目中用到的关键依赖,如MyBatis-Plus、Hutool等。简要提及了系统配置表、部门表、字典表等表结构。使用Hutool-jwt工具类进行JWT校验。配置忽略路径、禁用CSRF、添加JWT校验过滤器等。实现登录接口,返回token等信息。
179 12
|
1月前
|
Java 数据库连接 Maven
最新版 | 深入剖析SpringBoot3源码——分析自动装配原理(面试常考)
自动装配是现在面试中常考的一道面试题。本文基于最新的 SpringBoot 3.3.3 版本的源码来分析自动装配的原理,并在文未说明了SpringBoot2和SpringBoot3的自动装配源码中区别,以及面试回答的拿分核心话术。
最新版 | 深入剖析SpringBoot3源码——分析自动装配原理(面试常考)
|
17天前
|
Java 测试技术 应用服务中间件
Spring Boot 如何测试打包部署
本文介绍了 Spring Boot 项目的开发、调试、打包及投产上线的全流程。主要内容包括: 1. **单元测试**:通过添加 `spring-boot-starter-test` 包,使用 `@RunWith(SpringRunner.class)` 和 `@SpringBootTest` 注解进行测试类开发。 2. **集成测试**:支持热部署,通过添加 `spring-boot-devtools` 实现代码修改后自动重启。 3. **投产上线**:提供两种部署方案,一是打包成 jar 包直接运行,二是打包成 war 包部署到 Tomcat 服务器。
42 10
|
18天前
|
存储 安全 Java
Spring Boot 3 集成Spring AOP实现系统日志记录
本文介绍了如何在Spring Boot 3中集成Spring AOP实现系统日志记录功能。通过定义`SysLog`注解和配置相应的AOP切面,可以在方法执行前后自动记录日志信息,包括操作的开始时间、结束时间、请求参数、返回结果、异常信息等,并将这些信息保存到数据库中。此外,还使用了`ThreadLocal`变量来存储每个线程独立的日志数据,确保线程安全。文中还展示了项目实战中的部分代码片段,以及基于Spring Boot 3 + Vue 3构建的快速开发框架的简介与内置功能列表。此框架结合了当前主流技术栈,提供了用户管理、权限控制、接口文档自动生成等多项实用特性。
69 8