当前位置: 首页 > news >正文

使用Elasticsearch做网站google ads 推广

使用Elasticsearch做网站,google ads 推广,帝国网站建设,jquery加速wordpress目录地址: SpringCloudAlibaba整合-CSDN博客 这里只关注代码部分,至于sentinel服务UI的实用,后面可以补上 这里做一个改造: 因为sentinel可以和openfeign结合使用,为微服务做熔断降级; 为了方便微服务之间…

目录地址:

SpringCloudAlibaba整合-CSDN博客

这里只关注代码部分,至于sentinel服务UI的实用,后面可以补上

这里做一个改造:

因为sentinel可以和openfeign结合使用,为微服务做熔断降级;

为了方便微服务之间的调用,把远程调用接口移动到api模块;

所以把order中的openfeign和loadbalancer依赖,放到api的pom中,并且把order中Remote接口,移动到api中;后续order只需要引入api的依赖,调用api中的接口即可

1.在api中引入sentinel和openfeign

<!--openfeign-->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency><!--loadbalancer-->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency><!--sentinel-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

2.把接口从order转移到api,并修改

@FeignClient(name="my-user", fallbackFactory = UserServiceFactory.class)
public interface RemoteUserService {@RequestMapping("/user/listAll")public List<User> listAll();@GetMapping("/user/getById")public User getById(@RequestParam("id") Integer id);
}

api模块,添加UserServiceFactory类

@Component
public class UserServiceFactory implements FallbackFactory<RemoteUserService> {@Overridepublic RemoteUserService create(Throwable cause) {return new RemoteUserService() {@Overridepublic List<User> listAll() {return null;}@Overridepublic User getById(Integer id) {System.out.println("user服务异常");return null;}};}
}

3.注意要把UserServiceFactory放到META-INF/spring.factories文件中

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.test.api.remote.fallbackFactory.UserServiceFactory,\
com.test.api.remote.fallbackFactory.ProductServiceFactory

4.order引入api依赖,并在启动类添加注解,扫描feignClient接口

@EnableFeignClients(basePackages = {"com.test.api.remote"})

5.order的配置文件添加

feign:sentinel:enabled: true

6.重启服务,访问接口,正常访问

此时停止user服务,再次访问order接口,返回null,后台日志打印“user服务异常”

http://www.hkea.cn/news/372981/

相关文章:

  • 上海做b2b网站公司深圳公司网络推广该怎么做
  • 自己做的网站怎么在百度可以查到网络小说网站三巨头
  • 怎么做网站客服弹窗站长之家seo工具包
  • 自己建一个电商网站吗网络营销的定义
  • 专门做金融的招聘网站四川seo选哪家
  • wordpress nginx伪静态配置拼多多seo怎么优化
  • 深圳网站开发电话惠州网络营销
  • 中宁网站建设公司商城全网推广运营公司
  • 网站文章列表如何排版郑州seo技术培训班
  • 小型b2c网站百度开户渠道商哪里找
  • 武进区住房和城乡建设局网站爱站网能不能挖掘关键词
  • APP手机端电子商务网站建设营销成功的案例
  • 公司网站引导页百度搜索关键词排名优化技术
  • 网站开发与维护学什么网站建设seo优化培训
  • 常州网站开发百度网盘电脑版官网
  • wordpress安全权限关键词优化公司哪家好
  • 银川做网站服务google play下载安卓
  • 科技型中小企业服务网安徽搜索引擎优化seo
  • 网站建设专家排名邯郸seo营销
  • 做网站一个月20g流量够吗安全又舒适的避孕方法有哪些
  • 扫二维码直接进网站怎么做怎么提交网址让百度收录
  • 柳州建设局网站广告买卖网
  • 做外贸一般上哪些网站google play谷歌商店
  • 泉州手机网站制作如何做企业产品推广
  • 徐州手机网站设计汕头网站建设优化
  • 有没有专业收费做网站优化的百度百科优化排名
  • 常州网站建设哪家便宜江西seo推广软件
  • 如何用pageadmin做网站品牌宣传策略有哪些
  • 网站免费优化软件需要优化的地方
  • 24小时学会网站建设下载厦门百度竞价开户