【微服務】之一:第一個SpringBoot項目

一、SpringCloud子項目介紹

  Spring Cloud Config:配置管理開發工具包,可以讓你把配置放到遠程服務器,目前支持本地存儲、Git以及Subversion。
  Spring Cloud Bus:事件、消息總線,用於在集羣(例如,配置變化事件)中傳播狀態變化,可與Spring Cloud Config聯合實現熱部署。
  Spring Cloud Netflix:針對多種Netflix組件提供的開發工具包,其中包括Eureka、Hystrix、Zuul、Archaius等。
  Netflix Eureka:雲端負載均衡,一個基於 REST 的服務,用於定位服務,以實現雲端的負載均衡和中間層服務器的故障轉移。
  Netflix Hystrix:容錯管理工具,旨在通過控制服務和第三方庫的節點,從而對延遲和故障提供更強大的容錯能力。
  Netflix Zuul:邊緣服務工具,是提供動態路由,監控,彈性,安全等的邊緣服務。
  Netflix Archaius:配置管理API,包含一系列配置管理API,提供動態類型化屬性、線程安全配置操作、輪詢框架、回調機制等功能。
  Spring Cloud for Cloud Foundry:通過Oauth2協議綁定服務到CloudFoundry,CloudFoundry是VMware推出的開源PaaS雲平臺。
  Spring Cloud Sleuth:日誌收集工具包,封裝了Dapper,Zipkin和HTrace操作。
  Spring Cloud Data Flow:大數據操作工具,通過命令行方式操作數據流。
  Spring Cloud Security:安全工具包,爲你的應用程序添加安全控制,主要是指OAuth2。
  Spring Cloud Consul:封裝了Consul操作,consul是一個服務發現與配置工具,與Docker容器可以無縫集成。
  Spring Cloud Zookeeper:操作Zookeeper的工具包,用於使用zookeeper方式的服務註冊和發現。
  Spring Cloud Stream:數據流操作開發包,封裝了與Redis,Rabbit、Kafka等發送接收消息。
  Spring Cloud CLI:基於 Spring Boot CLI,可以讓你以命令行方式快速建立雲組件。

二、使用spring Boot創建第一個應用

1、先在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.xiaohang</groupId>
    <artifactId>demo1</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.0.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>springloaded</artifactId>
                        <version>1.2.5.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

2、創建啓動類Application.class

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

大功告成!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章