1.Spring Cloud是一个工具集:Spring   Cloud是在Spring    Boot的基础上构建的,用于简化分布式系统构建的工具集;使架构师在创建和发布微服务时极为便捷和有效.

Spring Cloud解决分布式中的问题:

项目

详细

No.1

配置管理

No.2

控制总线

No.3

集群管理

No.4

安全机制

No.5

Session管理

No.6

Failback

No.7

智能路由

No.8

网关管理

No.9

服务管理(服务发现/服务注册等)

2.Spring Boot简介

Spring Boot可以帮助开发者更容易地创建基于Spring的应用程序和服务。

Spring Boot的作用在于创建和启动新的基于Spring框架的项目。

Spring Boot会选择最适合的Spring子项目和第三方开源库进行整合。

大部分Spring Boot应用只需要非常少的配置就可以快速运行起来。

Spring Boot包含的特性如下

   创建可以独立运行的Spring应用。

  直接嵌入Tomcat或Jetty服务器,不需要部署WAR文件。

  提供推荐的基础POM文件来简化Apache Maven配置。

  尽可能的根据项目依赖来自动配置Spring框架。

  提供可以直接在生产环境中使用的功能,如性能指标、应用信息和应用健康检查。

  没有代码生成,也没有XML配置文件。

服务发现和智能路由

3. Spring Boot入门: Hello World

建一个空的MAVEN项目myproject

POM.xml

<?xml   version="1.0"  encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version> <!--使用最新的spring-boot版本 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent> <dependencies><!--web应用基本环境配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies> <!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> <!-- Add Spring repositories -->
<!-- (you don't need this if you are using a .RELEASE version) -->
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories> </project>

发布服务

package com.springboot.test;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
@EnableAutoConfiguration
public class Example { @RequestMapping("/hello1")
String home() {
return "Hello World!";
} @RequestMapping("/hello2/{myName}")
String index(@PathVariable String myName) {
return "Hello "+myName+"!!!";
}
}

启动类

package com.springboot.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class Application { public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

测试

在浏览器中输入:

http://localhost:8080/hello1

http://localhost:8080/hello2/chenxiaobing

  

微服务学习笔记一:Spring Cloud简介的更多相关文章

  1. Spring Cloud微服务学习笔记

    Spring Cloud微服务学习笔记 SOA->Dubbo 微服务架构->Spring Cloud提供了一个一站式的微服务解决方案 第一部分 微服务架构 1 互联网应用架构发展 那些迫使 ...

  2. SpringCloud微服务学习笔记

    SpringCloud微服务学习笔记 项目地址: https://github.com/taoweidong/Micro-service-learning 单体架构(Monolithic架构) Mon ...

  3. 微服务学习笔记(1)——使用MagicOnion实现gRPC

    原文:微服务学习笔记(1)--使用MagicOnion实现gRPC 1.什么是gRPC 官方文档:https://grpc.io/docs/guides/index.html 2.什么是MagicOn ...

  4. 微服务学习笔记(2)——使用Consul 实现 MagicOnion(GRpc) 服务注册和发现

    原文:微服务学习笔记(2)--使用Consul 实现 MagicOnion(GRpc) 服务注册和发现 1.下载打开Consul 笔者是windows下面开发的(也可以使用Docker). 官网下载w ...

  5. 【SpringCloud构建微服务系列】使用Spring Cloud Config统一管理服务配置

    一.为什么要统一管理微服务配置 对于传统的单体应用而言,常使用配置文件来管理所有配置,比如SpringBoot的application.yml文件,但是在微服务架构中全部手动修改的话很麻烦而且不易维护 ...

  6. 微服务实战SpringCloud之Spring Cloud Feign替代HTTP Client

    简介 在项目中我们有时候需要调用第三方的API,微服务架构中这种情况则更是无法避免--各个微服务之间通信.比如一般的项目中,有时候我们会使用 HTTP Client 发送 HTTP 请求来进行调用,而 ...

  7. 微服务生态组件之Spring Cloud OpenFeign详解和源码分析

    Spring Cloud OpenFeign 概述 Spring Cloud OpenFeign 官网地址 https://spring.io/projects/spring-cloud-openfe ...

  8. Spring Cloud 微服务四:熔断器Spring cloud hystrix

    前言:在微服务架构中,一般都是进程间通信,有可能调用链都比较长,当有底层某服务出现问题时,比如宕机,会导致调用方的服务失败,这样就会发生一连串的反映,造成系统资源被阻塞,最终可能造成雪崩.在sprin ...

  9. docker入门与部署微服务--学习笔记

    最近公司进一步去windows,走向 linux+云化. 原来的一大坨windows虚拟机服务器都要转向linux, 既然走向linux的话,那么docker肯定是要涉足的. 故学习了docker入门 ...

随机推荐

  1. ORA-03113 : end-of-file on communication channel

    现象一: 数据库startup时,出现数据库无法正常mount,并报ORA-03113错误. SQL> startup ORACLE instance started. Total System ...

  2. 下载azure website的code

    1.登陆kudu直接下载. http://www.concurrency.com/blog/use-azure-kudu-debug-azure-websites/ 2.FTP链接拷贝(可以忽略) 3 ...

  3. AF 与 PF区别

    AF 表示ADDRESS FAMILY 地址族 PF 表示PROTOCL FAMILY 协议族 Winsock2.h中#define AF_INET 0#define PF_INET AF_INET ...

  4. 【webservice】Two classes have the same XML type name(转)

    引言 需要调用另一个系统的提供的webservice接口,但是调用之后总是报错,用SoapUI测试接口却没有问题: 那就应该是代码的问题了,但是同样的代码也调用过其他系统却没有问题,不过最终还是解决了 ...

  5. R语言常用包汇总

    转载于:https://blog.csdn.net/sinat_26917383/article/details/50651464?locationNum=2&fps=1 一.一些函数包大汇总 ...

  6. HDU - 1907 anti-SG

    题意:nim游戏,最后取光为[输] anti-SG的应用,搬运一下我的摸鱼小笔记 最先看到的应该是分奇偶的非充裕堆判断,若为偶数则先手胜,否则后手胜 按SG分类 SG!=0时 1.只有一堆大于1,先手 ...

  7. PIE SDK主/次要分析

    1.算法功能简介 主要分析功能是采用类似卷积滤波的方法将较大类别中的虚假像元归到该类中,首先定义一个变换核尺寸,然后用变换核中占主要地位(像元最多)类别数代替中心像元的类别数,次要分析相反,用变换核中 ...

  8. D15 模块

    模块

  9. vue之element-ui文件上传

    vue之element-ui文件上传 文件上传需求 ​ 对于文件上传,实际项目中我们的需求一般分两种: 对于单个的文件上传,比如拖动上传个图片之类的,或者是文件. 和表单一起实现上传(这种情况一般都是 ...

  10. (转) sync命令

    sync sync命令 sync命令用于强制被改变的内容立刻写入磁盘,更新超块信息. 在Linux/Unix系统中,在文件或数据处理过程中一般先放到内存缓冲区中,等到适当的时候再写入磁盘,以提高系统的 ...