本文共 3745 字,大约阅读时间需要 12 分钟。
dubbo-provider.xml
dubbo-consumer-dev.xml
web.xml
Archetype Created Web Application spring.profiles.active dev com.alibaba.dubbo.remoting.http.servlet.BootstrapListener org.springframework.web.context.ContextLoaderListener dis com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet 1 dis /* dispatcher org.springframework.web.servlet.DispatcherServlet 1 dispatcher /oauth/token contextConfigLocation classpath:spring/spring-context.xml springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /*
dubbo-provider.xml
实现类: EnterpriseRestServiceImpl
package com.ctoedu.learn.restservice.impl;import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;import com.ctoedu.learn.mybatis.domain.Enterprise;import com.ctoedu.learn.repo.IEnterpriseService;import com.ctoedu.learn.restservice.IEnterpriseRestService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.web.bind.annotation.RequestBody;import javax.ws.rs.*;import javax.ws.rs.core.MediaType;@Path("/")//@Consumes({ MediaType.APPLICATION_JSON, MediaType.TEXT_XML, MediaType.APPLICATION_FORM_URLENCODED })//@Produces({ ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8 })@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})@Produces({ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})@Service("enterpriseRestService")public class EnterpriseRestServiceImpl implements IEnterpriseRestService { @Autowired IEnterpriseService enterpriseService; @Path("/getenterprise/{id}") @GET public Enterprise getEnterpriseById(@PathParam("id") int id) { return enterpriseService.getEnterpriseById(id); } @Path("/insertenterprise") @POST public void insertEnterprise(@RequestBody Enterprise enterprise) { // TODO Auto-generated method stub enterpriseService.insertEnterprise(enterprise); } @Path("/getstring/{name}") @GET public String getString(@PathParam("name") String name) { return name; } @Path("/deleteenterprise/{id}") @DELETE public void deleteEnterprise(@PathParam("id") int enterpriseId) { enterpriseService.deleteEnterprise(enterpriseId); }}
转载地址:http://slonn.baihongyu.com/