Honghu Cloud 分佈式微服務雲系統-Eureka spring
咱們針對於HongHu cloud的eureka項目作如下構建,整個構建的過程很簡單,我會將每一步都構建過程記錄下來,但願能夠幫助到你們。apache
<?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>commonservice</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>commonservice-eureka</artifactId> <packaging>jar</packaging> <name>commonservice-eureka</name> <description>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 @SpringBootApplication public class ServiceApplication{ public static void main(String[] args) { SpringApplication.run(ServiceApplication.class, args); }
3.配置application.yml文件app
# server (eureka 默認端口爲:8761) server: port: 8761 # spring spring: application: name: commonservice-erueka # eureka eureka: client: # 是否註冊到 eureka register-with-eureka: true # 是否從 eureka 獲取註冊信息 fetch-registry: false availability-zones: honghu: honghuZone service-url: honghuZone: http://honghu:123456@localhost:8761/eureka/ defaultZone: http://honghu:123456@localhost: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: 123456management: security: enabled: false
Centos下的打包部署機制)框架
訪問控制檯並登錄:
maven
控制檯運行效果:
分佈式
在開始,我這邊會將近期研發的spring cloud微服務雲架構的搭建過程和精髓記錄下來,幫助更多有興趣研發spring cloud框架的朋友,你們來一塊兒探討spring cloud架構的搭建過程及如何運用於企業項目。ide
願意瞭解框架技術或者源碼的朋友直接求求交流分享技術1791743380spring-boot