springcloud的commonservice-eureka項(xiàng)目怎么構(gòu)建

本篇內(nèi)容介紹了“spring cloud的commonservice-eureka項(xiàng)目怎么構(gòu)建”的有關(guān)知識,在實(shí)際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)吉縣,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792

1. 創(chuàng)建一個名為particle-common-eureka的maven項(xiàng)目,繼承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的相關(guān)配置,代碼如下:

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文件

# server (eureka 默認(rèn)端口為:8761)  
server:  
  port: 8761  
  
# spring  
spring:  
  application:  
    name: particle-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}  
        
  # 指定環(huán)境  
  environment: dev  
  #指定數(shù)據(jù)中心  
  datacenter: honghu  
  # 關(guān)閉自我保護(hù)模式  
  server:   
    enable-self-preservation: false  
  #設(shè)置清理無效節(jié)點(diǎn)的時間間隔,默認(rèn)60000,即是60s  
    eviction-interval-timer-in-ms: 60000  
  
# 服務(wù)認(rèn)證  
security:   
  basic:   
    enabled: true  
  user:   
    name: honghu  
    password: 123456  
  
management:  
  security:  
    enabled: false

4. 增加項(xiàng)目的log機(jī)制和打包運(yùn)行機(jī)制(后面我們會詳細(xì)編寫針對于Linux Centos下的打包部署機(jī)制)

5. 自此整個項(xiàng)目部署完成,通過手動方式進(jìn)行Run As --> Spring Boot App,運(yùn)行結(jié)果如下:

控制臺運(yùn)行結(jié)果:

spring cloud的commonservice-eureka項(xiàng)目怎么構(gòu)建

訪問控制臺并登陸:

spring cloud的commonservice-eureka項(xiàng)目怎么構(gòu)建

控制臺運(yùn)行效果:

spring cloud的commonservice-eureka項(xiàng)目怎么構(gòu)建

“spring cloud的commonservice-eureka項(xiàng)目怎么構(gòu)建”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

文章名稱:springcloud的commonservice-eureka項(xiàng)目怎么構(gòu)建
文章出自:http://bm7419.com/article16/pcsjdg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計(jì)公司、關(guān)鍵詞優(yōu)化、靜態(tài)網(wǎng)站、云服務(wù)器、響應(yīng)式網(wǎng)站、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)