spring cloud雲端服務架構 - HongHu commonservice-eureka 項目構建過程

來源:互聯網
上載者:User

標籤:服務   過程   ddr   common   lin   style   打包部署   commons   address   

上一篇我們回顧了關於 spring cloud eureka的相關基礎知識,現在我們針對於HongHu cloud的eureka項目做以下構建,整個構建的過程很簡單,我會將每一步都構建過程記錄下來,希望可以協助到大家:

1. 建立一個名為particle-common-eureka的maven項目,繼承particle-commonservice,具體的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>     <parent>        <groupId>com.ml.honghu</groupId>        <artifactId>particle-commonservice</artifactId>        <version>0.0.1-SNAPSHOT</version>    </parent>     <artifactId>particle-commonservice-eureka</artifactId>    <packaging>jar</packaging>     <name>particle-commonservice-eureka</name>    <description>particle-commonservice project for Spring Boot</description>     <dependencies>        <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-starter-eureka-server</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-security</artifactId>        </dependency>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-devtools</artifactId>        </dependency>                <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-test</artifactId>            <scope>test</scope>        </dependency>     </dependencies>     <build>        <plugins>            <plugin>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-maven-plugin</artifactId>                <executions>                    <execution>                        <id>1</id>                        <goals>                            <goal>repackage</goal>                        </goals>                    </execution>                    <execution>                        <id>2</id>                        <goals>                            <goal>build-info</goal>                        </goals>                    </execution>                </executions>                <configuration>                    <executable>true</executable>                </configuration>                            </plugin>        </plugins>    </build></project>

2. 在啟動類入口引用eureka的相關配置,代碼如下:

package com.ml.honghu; import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @EnableEurekaServer@SpringBootApplicationpublic class ServiceApplication {     public static void main(String[] args) {        SpringApplication.run(ServiceApplication.class, args);    }}

3. 配置application.yml檔案

# server (eureka 預設連接埠為:8761)server:  port: 8761 # springspring:  application:    name: particle-commonservice-erueka # eurekaeureka:   client:     # 是否註冊到eureka    register-with-eureka: true    # 是否從eureka擷取註冊資訊    fetch-registry: false    availability-zones:       honghu: honghuZone    service-url:       honghuZone: http://honghu:[email protected]:8761/eureka/      defaultZone: http://honghu:[email protected]:8761/eureka/  instance:    prefer-ip-address: true    hostname: localhost    metadataMap:      zone: honghuZone      user: ${security.user.name}      password: {security.user.password}        # 指定環境  environment: dev  #指定資料中心  datacenter: honghu  # 關閉自我保護模式  server:     enable-self-preservation: false  #設定清理無效節點的時間間隔,預設60000,即是60s    eviction-interval-timer-in-ms: 60000 # 服務認證security:   basic:     enabled: true  user:     name: honghu    password: 123456 management:  security:    enabled: false

4. 增加項目的log機制和打包運行機制(後面我們會詳細編寫針對於Linux Centos下的打包部署機制)

5. 自此整個項目部署完成,通過手動方式進行Run As --> Spring Boot App,運行結果如下:

控制台運行結果:

存取控制台並登陸:

控制台運行效果:

從現在開始,我這邊會將近期研發的spring cloud微服務雲架構的搭建過程和精髓記錄下來,協助更多有興趣研發spring cloud架構的朋友,大家來一起探討spring cloud架構的搭建過程及如何運用於企業專案。 

完整項目的源碼來源 支援人員求求1791743380

spring cloud雲端服務架構 - HongHu commonservice-eureka 項目構建過程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.