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

公司网站要怎么做/有哪些可以免费推广的平台

公司网站要怎么做,有哪些可以免费推广的平台,注册电气工程师,制作一个网站数据库怎么做Spring Cloud是什么 Spring Cloud是一系列框架的有序集合。它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册、配置中心、消息总线、负载均衡、断路器、数据监控等,都可以用Spring Boot的开发风格做到一键启动和部署。…

Spring Cloud是什么

Spring Cloud是一系列框架的有序集合。它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册、配置中心、消息总线、负载均衡、断路器、数据监控等,都可以用Spring Boot的开发风格做到一键启动和部署。Spring并没有重复制造轮子,它只是将目前各家公司开发的比较成熟、经得起实际考验的服务框架组合起来,通过Spring Boot风格进行再封装屏蔽掉了复杂的配置和实现原理,最终给开发者留出了一套简单易懂、易部署和易维护的分布式系统开发工具包。

微服务是可以独立部署、水平扩展、独立访问(或者有独立的数据库)的服务单元,springcloud就是这些微服务的大管家,采用了微服务这种架构之后,项目的数量会非常多,springcloud做为大管家需要管理好这些微服务,自然需要很多小弟来帮忙。

和Spring Boot 是什么关系

Spring Boot 是 Spring 的一套快速配置脚手架,可以基于Spring Boot 快速开发单个微服务,Spring Cloud是一个基于Spring Boot实现的云应用开发工具;Spring Boot专注于快速、方便集成的单个个体,Spring Cloud是关注全局的服务治理框架;Spring Boot使用了默认大于配置的理念,很多集成方案已经帮你选择好了,能不配置就不配置,Spring Cloud很大的一部分是基于Spring Boot来实现,可以不基于Spring Boot吗?不可以。

Spring Boot可以离开Spring Cloud独立使用开发项目,但是Spring Cloud离不开Spring Boot,属于依赖的关系。

    spring -> spring booot > Spring Cloud 这样的关系。

Spring Cloud的优势

微服务的框架那么多比如:dubbo、Kubernetes,为什么就要使用Spring Cloud的呢?

  • 产出于spring大家族,spring在企业级开发框架中无人能敌,来头很大,可以保证后续的更新、完善。比如dubbo现在就差不多死了
  • 有Spring Boot 这个独立干将可以省很多事,大大小小的活Spring Boot都搞的挺不错。
  • 作为一个微服务治理的大家伙,考虑的很全面,几乎服务治理的方方面面都考虑到了,方便开发开箱即用。
  • Spring Cloud 活跃度很高,教程很丰富,遇到问题很容易找到解决方案
  • 轻轻松松几行代码就完成了熔断、均衡负责、服务中心的各种平台功能

Spring Cloud对于中小型互联网公司来说是一种福音,因为这类公司往往没有实力或者没有足够的资金投入去开发自己的分布式系统基础设施,使用Spring Cloud一站式解决方案能在从容应对业务发展的同时大大减少开发成本。同时,随着近几年微服务架构和Docker容器概念的火爆,也会让Spring Cloud在未来越来越“云”化的软件开发风格中立有一席之地,尤其是在目前五花八门的分布式解决方案中提供了标准化的、全站式的技术方案,意义可能会堪比当前Servlet规范的诞生,有效推进服务端软件系统技术水平的进步。

Spring Cloud Eureka

我们用Spring Cloud Eureka来实现服务治理。

创建“服务注册中心”

创建一个基础的Spring Boot工程,命名为springboot-register,并在pom.xml中引入需要的依赖内容:

 1 <dependencies>
 2         <dependency>
 3             <groupId>org.springframework.boot</groupId>
 4             <artifactId>spring-boot-starter-web</artifactId>
 5         </dependency>
 6 
 7         <dependency>
 8             <groupId>org.springframework.cloud</groupId>
 9             <artifactId>spring-cloud-starter-eureka-server</artifactId>
10         </dependency>
11         <dependency>
12             <groupId>org.springframework.boot</groupId>
13             <artifactId>spring-boot-starter-test</artifactId>
14             <scope>test</scope>
15         </dependency>
16     </dependencies>
17     <dependencyManagement>
18         <dependencies>
19             <dependency>
20                 <groupId>org.springframework.cloud</groupId>
21                 <artifactId>spring-cloud-dependencies</artifactId>
22                 <version>Brixton.SR5</version>
23                 <type>pom</type>
24                 <scope>import</scope>
25             </dependency>
26         </dependencies>
27     </dependencyManagement>

通过@EnableEurekaServer注解启动一个服务注册中心提供给其他应用进行对话:

@EnableEurekaServer
@SpringBootApplication
public class ApplicationRegister {public static void main(String[] args) {SpringApplication.run(ApplicationRegister.class, args);}
}

application.properties配置文件中增加如下信息:

server.port=1111
eureka.server.enable-self-preservation=false
eureka.instance.hostname=localhost
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/

访问:http://localhost:1111/ ,如图所示:

页面中还没有任何服务!

 

注册“服务提供方”

创建一个基本的Spring Boot应用。命名为spring boot-client,在pom.xml中,加入如下配置:

 1 <dependency>
 2             <groupId>org.springframework.boot</groupId>
 3             <artifactId>spring-boot-starter-web</artifactId>
 4         </dependency>
 5 
 6         <dependency>
 7             <groupId>org.springframework.cloud</groupId>
 8             <artifactId>spring-cloud-starter-eureka-server</artifactId>
 9         </dependency>
10         <dependency>
11             <groupId>org.springframework.boot</groupId>
12             <artifactId>spring-boot-starter-test</artifactId>
13             <scope>test</scope>
14         </dependency>
15     </dependencies>
16     <dependencyManagement>
17         <dependencies>
18             <dependency>
19                 <groupId>org.springframework.cloud</groupId>
20                 <artifactId>spring-cloud-dependencies</artifactId>
21                 <version>Brixton.SR5</version>
22                 <type>pom</type>
23                 <scope>import</scope>
24             </dependency>
25         </dependencies>
26     </dependencyManagement>

编写一个controller:

 1 @RestController
 2 public class HelloController {
 3     private final Logger logger = Logger.getLogger(getClass());
 4 
 5     @Autowired
 6     private DiscoveryClient client;
 7 
 8     @RequestMapping(value = "/hello", method = RequestMethod.GET)
 9     public String index() throws Exception{
10        
11         return "Hello World";
12     }
13 }

最后在应用主类中通过加上@EnableDiscoveryClient注解,实现Controller中对服务信息的输出:

1 @EnableDiscoveryClient
2 @SpringBootApplication
3 public class ApplicationClient {
4 
5     public static void main(String[] args) {
6         SpringApplication.run(ApplicationClient.class, args);
7     }
8 
9 }

在application.properties配置文件中增加如下信息:

server.port=2224spring.application.name=hello-service
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/

启动该工程后,再次访问:http://localhost:1111/ ,如图:

我们也可以通过直接访问spring boot-client服务提供的/hello接口,访问:http://localhost:2224/hello,得到如下输出:

这样我们的服务注册与发现就完成了。

 

剔除过期等不健康实例(生产环境不建议使用)

server端:

  

1.关闭注册中心自我保护机制eureka.server.enable-self-preservation:false
2.注册中心清理间隔(单位毫秒,默认60*1000)eureka.server.eviction-interval-timer-in-ms:10000

client端:

  

1.开启健康检查(需要spring-boot-starter-actuator依赖)eureka.client.healthcheck.enabled:true
2.租期更新时间间隔(默认30秒)eureka.instance.lease-renewal-interval-in-seconds=10
3.租期到期时间(默认90秒)eureka.instance.lease-expiration-duration-in-seconds=15

以上参数配置下来,从服务停止,到注册中心清除不健康实例,时间大约在30秒左右。租期到期时间为30秒时,清除时间大约在59秒,若采用默认的30-60配置,清除时间大约在2分半(以上均在关闭保护机制情况下),生产环境建议采用默认配置,服务停止到注册中心清除实例之间有一些计算什么的。

转载于:https://www.cnblogs.com/heqiyoujing/p/9212600.html

http://www.lbrq.cn/news/1469143.html

相关文章:

  • 嘉兴做网站优化哪家好/中国互联网公司排名
  • 深圳市住房和建设委员会网站/外链相册
  • 烟台网站建设开发/百度账号登录入口
  • 营销型网站建设哪个好/seo搜索引擎是什么
  • 怎样做外国石雕产品网站/seo优化方案报价
  • 怎么在阿里巴巴网站做公司/今日头条新闻视频
  • 郑州专业制作网站多少钱/类似凡科建站的平台
  • 网站建设公司线下推广/网络舆情管理
  • wordpress 改网站域名/廊坊seo排名
  • 烟台做网站/美国最新新闻头条
  • 长沙网站建设的公司/如何写推广软文
  • discuz论坛和网站同步登录/陕西网络推广公司
  • 铜川网站建设/百度产品大全入口
  • 电子购物网站/seo搜索引擎推广
  • 作风建设简报--门户网站/seo sem是什么
  • b2c网站 方案/企业官网seo
  • 网站建设现在什么服务器比较好/南召seo快速排名价格
  • wordpress的登录界面/关键词首页排名优化价格
  • 上海网站推广服务公司/百度的首页
  • 阀门专业网站建设/云南百度推广开户
  • 做彩妆网站的公司/优化营商环境心得体会个人
  • 中华人民共和国城乡与建设部网站/北京口碑最好的教育机构
  • 成都市建设网站公司/网络推广和seo
  • 网站双链接怎么做/网站数据统计工具
  • 网站备案 前置审批文件/杭州seo搜索引擎优化公司
  • 做301网站打不开/百度一下你就知道啦
  • 做教育机构的设计哪些网站好/域名网
  • 最新网站源码/宁波seo关键词排名优化
  • 网页游戏平台代理加盟/太原seo关键词排名
  • 上海网络建设公司/深圳seo优化外包公司
  • Allegro降版本工具
  • cv弹窗,退款确认弹窗
  • 函数指针——回调函数
  • PYTHON从入门到实践-18Django从零开始构建Web应用
  • LVGL + ESP-Brookesia 在Windows下的编译和运行
  • Flutter基础知识