Merge branch 'develop' into registry-nacos

pull/1/head
tanghc 5 years ago
commit fce0b4d242
  1. 53
      sop-admin/sop-admin-server/src/main/resources/application-dev.properties
  2. 1
      sop-admin/sop-admin-server/src/main/resources/application.properties
  3. 7
      sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/controller/DubboConsumerController.java
  4. 19
      sop-example/sop-book/sop-book-web/src/main/resources/application-dev.properties
  5. 1
      sop-example/sop-book/sop-book-web/src/main/resources/application.properties
  6. 4
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java
  7. 3
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/service/DefaultDemoService.java
  8. 25
      sop-example/sop-story/sop-story-web/src/main/resources/application-dev.properties
  9. 1
      sop-example/sop-story/sop-story-web/src/main/resources/application.properties
  10. 52
      sop-gateway/src/main/resources/application-dev.properties
  11. 1
      sop-gateway/src/main/resources/application.properties
  12. 14
      sop-registry/src/main/resources/application-dev.properties
  13. 1
      sop-registry/src/main/resources/application.properties
  14. 30
      sop-website/website-server/src/main/resources/application-dev.properties
  15. 1
      sop-website/website-server/src/main/resources/application.properties

@ -0,0 +1,53 @@
server.port=8082
spring.application.name=sop-admin
# ------- 需要改的配置 -------
# mysql数据库账号
mysql.username=root
mysql.password=root
# eureka注册中心地址
eureka.url=http://localhost:1111/eureka/
# nacos注册中心地址
nacos.url=127.0.0.1:8848
# zookeeper地址
zookeeper.url=localhost:2181
# zipkin服务监控地址,没有开启不用改
zipkin.url=http://127.0.0.1:9411/
# ------- 需要改的配置end -------
######### 下面的配置基本不用改 #########
# token过期时间,分钟
admin.access-token.timeout-minutes=30
# 签名方式,rsa:支付宝开放平台签名方式,md5:淘宝开放平台签名方式
sop.sign-type=rsa
# zookeeper配置
spring.cloud.zookeeper.connect-string=${zookeeper.url}
spring.cloud.zookeeper.baseSleepTimeMs=3000
spring.cloud.zookeeper.maxRetries=3
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/sop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=${mysql.username}
spring.datasource.password=${mysql.password}
# 固定不用改
easyopen.show-doc=false
easyopen.ignore-validate=true
# 注册中心地址,根据实际情况改,这里只是参数,并不会去注册
registry.eureka-server-addr=${eureka.url}
registry.nacos-server-addr=${nacos.url}
# 使用eureka,填:eureka,使用nacos填:nacos
registry.name=eureka
logging.level.com.gitee=debug
# 不用改
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillInsert=gmt_create
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillUpdate=gmt_modified
# 不用改,如果要改,请全局替换修改
zuul.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC

@ -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.param.DemoParam;
import com.gitee.sop.story.api.result.DemoResult; import com.gitee.sop.story.api.result.DemoResult;
import com.gitee.sop.story.api.service.DemoService; import com.gitee.sop.story.api.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController; 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() * Feign的使用方式参见com.gitee.sop.bookweb.controller.AlipayBookController#getBook2()
*/ */
@RestController @RestController
@Slf4j
public class DubboConsumerController { public class DubboConsumerController {
@Reference(version = "${demo.service.version}", @Reference(version = "1.0.0", url = "dubbo://127.0.0.1:12345")
application = "${dubbo.application.id}",
url = "dubbo://localhost:12345")
private DemoService demoService; private DemoService demoService;
// 作为开放接口 // 作为开放接口
@ApiMapping(value = "dubbo.story.get") @ApiMapping(value = "dubbo.story.get")
public Story openApi(DemoParam demoParam) { public Story openApi(DemoParam demoParam) {
log.info("dubbo consumer, param: {}", demoParam);
// 通过dubbo调用story提供的服务 // 通过dubbo调用story提供的服务
DemoResult dubboStory = demoService.getStory(demoParam); DemoResult dubboStory = demoService.getStory(demoParam);
Story story = new Story(); 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

@ -8,6 +8,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -21,6 +22,7 @@ import java.util.Date;
* @author tanghc * @author tanghc
*/ */
@RestController @RestController
@Slf4j
@Api(tags = "故事接口") @Api(tags = "故事接口")
public class AlipayController { public class AlipayController {
@ -101,7 +103,7 @@ public class AlipayController {
@ApiOperation(value = "获取故事信息", notes = "说明接口的详细信息,介绍,用途,注意事项等。") @ApiOperation(value = "获取故事信息", notes = "说明接口的详细信息,介绍,用途,注意事项等。")
@ApiMapping(value = "alipay.story.find") @ApiMapping(value = "alipay.story.find")
public StoryVO getStory2(StoryParam story, HttpServletRequest request) { public StoryVO getStory2(StoryParam story, HttpServletRequest request) {
System.out.println(story); log.info("获取故事信息参数, story: {}", story);
// 获取其它参数 // 获取其它参数
System.out.println(request.getParameter("app_id")); System.out.println(request.getParameter("app_id"));
StoryVO storyVO = new StoryVO(); 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.param.DemoParam;
import com.gitee.sop.story.api.result.DemoResult; import com.gitee.sop.story.api.result.DemoResult;
import com.gitee.sop.story.api.service.DemoService; import com.gitee.sop.story.api.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@Service(version = "1.0.0") @Service(version = "1.0.0")
@Slf4j
public class DefaultDemoService implements DemoService { public class DefaultDemoService implements DemoService {
/** /**
@ -21,6 +23,7 @@ public class DefaultDemoService implements DemoService {
@Override @Override
public DemoResult getStory(DemoParam param) { public DemoResult getStory(DemoParam param) {
log.info("dubbo provider, param: {}", param);
DemoResult demoResult = new DemoResult(); DemoResult demoResult = new DemoResult();
demoResult.setId(param.getId()); demoResult.setId(param.getId());
demoResult.setName("dubbo 白雪公主, param=" + param); 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,52 @@
server.port=8081
# ------- 需要改的配置 -------
# mysql数据库账号
mysql.username=root
mysql.password=root
# eureka注册中心地址
eureka.url=http://localhost:1111/eureka/
# zookeeper地址
zookeeper.url=localhost:2181
# zipkin服务监控地址,没有开启不用改
zipkin.url=http://127.0.0.1:9411/
# ------- 需要改的配置end -------
######### 下面的配置基本不用改 #########
spring.application.name=api-gateway
# 入口地址,不用改,默认是/zuul
zuul.servlet-path=/api
# 禁用默认的过滤器,不能删,不用改
zuul.FormBodyWrapperFilter.pre.disable=true
zuul.Servlet30WrapperFilter.pre.disable=true
# 不用改,如果要改,请全局替换修改
zuul.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC
# https://blog.csdn.net/qq_36872046/article/details/81058045
# 路由转发超时时间,毫秒,默认值1000,详见:RibbonClientConfiguration.DEFAULT_READ_TIMEOUT。
# 如果微服务端 处理时间过长,会导致ribbon read超时,解决办法将这个值调大一点
ribbon.ReadTimeout=2000
# 设置为true(默认false),则所有请求都重试,默认只支持get请求重试
# 请谨慎设置,因为post请求大多都是写入请求,如果要支持重试,确保服务的幂等性
ribbon.OkToRetryOnAllOperations=false
eureka.client.serviceUrl.defaultZone=${eureka.url}
spring.cloud.zookeeper.connect-string=${zookeeper.url}
#spring.cloud.gateway.discovery.locator.lower-case-service-id=true
#spring.cloud.gateway.discovery.locator.enabled=true
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/sop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=${mysql.username}
spring.datasource.password=${mysql.password}
# 文件上传配置
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=20MB
spring.servlet.multipart.max-request-size=20MB
# zipkin服务跟踪
spring.zipkin.base-url=${zipkin.url}
# 设置sleuth收集信息的比率,默认0.1,最大是1,数字越大越耗性能
spring.sleuth.sampler.probability=1

@ -0,0 +1,14 @@
server.port=1111
spring.application.name=sop-registry
# ------- 需要改的配置 -------
# eureka注册中心地址
eureka.url=http://localhost:1111/eureka/
# ------- 需要改的配置end -------
######### 下面的配置基本不用改 #########
eureka.client.fetch-registry=false
eureka.client.register-with-eureka=false
eureka.client.serviceUrl.defaultZone=${eureka.url}

@ -0,0 +1,30 @@
server.port=8083
spring.application.name=website-server
# ------- 需要改的配置 -------
# eureka注册中心地址
eureka.url=http://localhost:1111/eureka/
# zookeeper地址
zookeeper.url=localhost:2181
# nacos地址
nacos.url=127.0.0.1:8848
# ------- 需要改的配置end -------
# 注册中心地址,根据实际情况改,这里只是参数,并不会去注册
registry.eureka-server-addr=${eureka.url}
# nacos服务器地址
registry.nacos-server-addr=${nacos.url}
# 使用eureka,填:eureka,使用nacos填:nacos
registry.name=eureka
spring.cloud.zookeeper.connect-string=${zookeeper.url}
# 测试环境
api.url-test=http://api-test.yourdomain.com/api
# 沙箱环境
api.url-sandbox=http://localhost:8081/api
# 正式环境
api.url-prod=http://open.yourdomain.com/api
api.pwd=doc#123
Loading…
Cancel
Save