mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
Merge branch 'develop' into registry-nacos
This commit is contained in:
@@ -6,6 +6,7 @@ import com.gitee.sop.story.api.domain.Story;
|
||||
import com.gitee.sop.story.api.param.DemoParam;
|
||||
import com.gitee.sop.story.api.result.DemoResult;
|
||||
import com.gitee.sop.story.api.service.DemoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
@@ -17,16 +18,16 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* Feign的使用方式参见:com.gitee.sop.bookweb.controller.AlipayBookController#getBook2()
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class DubboConsumerController {
|
||||
|
||||
@Reference(version = "${demo.service.version}",
|
||||
application = "${dubbo.application.id}",
|
||||
url = "dubbo://localhost:12345")
|
||||
@Reference(version = "1.0.0", url = "dubbo://127.0.0.1:12345")
|
||||
private DemoService demoService;
|
||||
|
||||
// 作为开放接口
|
||||
@ApiMapping(value = "dubbo.story.get")
|
||||
public Story openApi(DemoParam demoParam) {
|
||||
log.info("dubbo consumer, param: {}", demoParam);
|
||||
// 通过dubbo调用story提供的服务
|
||||
DemoResult dubboStory = demoService.getStory(demoParam);
|
||||
Story story = new Story();
|
||||
|
@@ -0,0 +1,19 @@
|
||||
server.port=3333
|
||||
spring.application.name=book-service
|
||||
spring.application.description=book服务
|
||||
|
||||
# eureka注册中心,如果使用nacos注册中心,这里要注释掉
|
||||
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
||||
# nacos注册中心
|
||||
# spring.nacos.discovery.server-addr=127.0.0.1:8848
|
||||
|
||||
# zookeeper配置
|
||||
spring.cloud.zookeeper.connect-string=localhost:2181
|
||||
|
||||
# zipkin服务跟踪
|
||||
spring.zipkin.base-url=http://127.0.0.1:9411/
|
||||
# 设置sleuth收集信息的比率,默认0.1,最大是1,数字越大越耗性能
|
||||
spring.sleuth.sampler.probability=1
|
||||
# dubbo使用zipkin过滤器
|
||||
dubbo.provider.filter=tracing
|
||||
dubbo.consumer.filter=tracing
|
@@ -0,0 +1 @@
|
||||
spring.profiles.active=dev
|
@@ -8,6 +8,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -21,6 +22,7 @@ import java.util.Date;
|
||||
* @author tanghc
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@Api(tags = "故事接口")
|
||||
public class AlipayController {
|
||||
|
||||
@@ -101,7 +103,7 @@ public class AlipayController {
|
||||
@ApiOperation(value = "获取故事信息", notes = "说明接口的详细信息,介绍,用途,注意事项等。")
|
||||
@ApiMapping(value = "alipay.story.find")
|
||||
public StoryVO getStory2(StoryParam story, HttpServletRequest request) {
|
||||
System.out.println(story);
|
||||
log.info("获取故事信息参数, story: {}", story);
|
||||
// 获取其它参数
|
||||
System.out.println(request.getParameter("app_id"));
|
||||
StoryVO storyVO = new StoryVO();
|
||||
|
@@ -4,9 +4,11 @@ import com.alibaba.dubbo.config.annotation.Service;
|
||||
import com.gitee.sop.story.api.param.DemoParam;
|
||||
import com.gitee.sop.story.api.result.DemoResult;
|
||||
import com.gitee.sop.story.api.service.DemoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@Service(version = "1.0.0")
|
||||
@Slf4j
|
||||
public class DefaultDemoService implements DemoService {
|
||||
|
||||
/**
|
||||
@@ -21,6 +23,7 @@ public class DefaultDemoService implements DemoService {
|
||||
|
||||
@Override
|
||||
public DemoResult getStory(DemoParam param) {
|
||||
log.info("dubbo provider, param: {}", param);
|
||||
DemoResult demoResult = new DemoResult();
|
||||
demoResult.setId(param.getId());
|
||||
demoResult.setName("dubbo 白雪公主, param=" + param);
|
||||
|
@@ -0,0 +1,25 @@
|
||||
server.port=2222
|
||||
spring.application.name=story-service
|
||||
spring.application.description=story服务
|
||||
|
||||
# eureka注册中心,如果使用nacos注册中心,这里要注释掉
|
||||
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
|
||||
# nacos注册中心
|
||||
# spring.nacos.discovery.server-addr=127.0.0.1:8848
|
||||
|
||||
# zookeeper配置
|
||||
spring.cloud.zookeeper.connect-string=localhost:2181
|
||||
|
||||
# dubbo配置
|
||||
dubbo.protocol.name=dubbo
|
||||
dubbo.protocol.port=12345
|
||||
dubbo.registry.address=N/A
|
||||
dubbo.scan.base-packages=com.gitee.sop.storyweb.service
|
||||
|
||||
# zipkin服务跟踪
|
||||
spring.zipkin.base-url=http://127.0.0.1:9411/
|
||||
# 设置sleuth收集信息的比率,默认0.1,最大是1,数字越大越耗性能
|
||||
spring.sleuth.sampler.probability=1
|
||||
# dubbo使用zipkin过滤器
|
||||
dubbo.provider.filter=tracing
|
||||
dubbo.consumer.filter=tracing
|
@@ -0,0 +1 @@
|
||||
spring.profiles.active=dev
|
Reference in New Issue
Block a user