Spring Boot Admin -nacos備份

服務端:

?pom.xml 引入包漫贞,注冊到nacos

<?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>org.springframework.boot</groupId>

? ? ? ? <artifactId>spring-boot-starter-parent</artifactId>

? ? ? ? <version>2.0.5.RELEASE</version>

? ? ? ? <relativePath/> <!-- lookup parent from repository -->

? ? </parent>

? ? <groupId>com.example</groupId>

? ? <artifactId>demo</artifactId>

? ? <version>0.0.1-SNAPSHOT</version>

? ? <name>demo</name>

? ? <description>Demo project for Spring Boot</description>

? ? <properties>

? ? ? ? <java.version>1.8</java.version>

? ? </properties>

? ? <dependencyManagement>

? ? ? ? <dependencies>

? ? ? ? ? ? <dependency>

? ? ? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>

? ? ? ? ? ? ? ? <artifactId>spring-cloud-dependencies</artifactId>

? ? ? ? ? ? ? ? <version>Finchley.SR1</version>

? ? ? ? ? ? ? ? <type>pom</type>

? ? ? ? ? ? ? ? <scope>import</scope>

? ? ? ? ? ? </dependency>

? ? ? ? ? ? <dependency>

? ? ? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>

? ? ? ? ? ? ? ? <artifactId>spring-cloud-alibaba-dependencies</artifactId>

? ? ? ? ? ? ? ? <version>0.2.1.RELEASE</version>

? ? ? ? ? ? ? ? <type>pom</type>

? ? ? ? ? ? ? ? <scope>import</scope>

? ? ? ? ? ? </dependency>

? ? ? ? </dependencies>

? ? </dependencyManagement>

? ? <dependencies>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>de.codecentric</groupId>

? ? ? ? ? ? <artifactId>spring-boot-admin-starter-server</artifactId>

? ? ? ? ? ? <version>2.0.1</version>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>de.codecentric</groupId>

? ? ? ? ? ? <artifactId>spring-boot-admin-server-ui</artifactId>

? ? ? ? ? ? <version>2.0.1</version>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.springframework.boot</groupId>

? ? ? ? ? ? <artifactId>spring-boot-starter-web</artifactId>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>

? ? ? ? ? ? <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>

? ? ? ? ? ? <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>

? ? ? ? ? ? <artifactId>spring-cloud-starter-openfeign</artifactId>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.projectlombok</groupId>

? ? ? ? ? ? <artifactId>lombok</artifactId>

? ? ? ? ? ? <version>1.18.2</version>

? ? ? ? ? ? <optional>true</optional>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.springframework.cloud</groupId>

? ? ? ? ? ? <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.springframework.boot</groupId>

? ? ? ? ? ? <artifactId>spring-boot-starter-data-redis</artifactId>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>org.mybatis.spring.boot</groupId>

? ? ? ? ? ? <artifactId>mybatis-spring-boot-starter</artifactId>

? ? ? ? ? ? <version>1.3.2</version>

? ? ? ? </dependency>

? ? ? ? <dependency>

? ? ? ? ? ? <groupId>mysql</groupId>

? ? ? ? ? ? <artifactId>mysql-connector-java</artifactId>

? ? ? ? ? ? <version>8.0.11</version>

? ? ? ? </dependency>

? ? </dependencies>

? ? <build>

? ? ? ? <plugins>

? ? ? ? ? ? <plugin>

? ? ? ? ? ? ? ? <groupId>org.springframework.boot</groupId>

? ? ? ? ? ? ? ? <artifactId>spring-boot-maven-plugin</artifactId>

? ? ? ? ? ? </plugin>

? ? ? ? </plugins>

? ? </build>

</project>

注入

@SpringBootApplication

@EnableFeignClients

@EnableAdminServer

@EnableDiscoveryClient

public class DemoApplication {

? ? public static void main(String[] args) {

? ? ? ? SpringApplication.run(DemoApplication.class, args);

? ? }

}

配置文件?

#開啟端點

management.endpoints.web.exposure.include=*

management.security.enabled=false

management.security.endpoint.health.show-details= ALWAYS


nacos配置,寫在bootstrap.properties配置文件里(當前nacos要求)亩进,自己的nacos的服務端ip端口

spring.application.name=springBootAdmin

spring.cloud.nacos.discovery.server-addr=192.168.1.31:8848

spring.cloud.nacos.config.server-addr=192.168.1.31:8848

啟動服務,在nacos發(fā)現(xiàn)服務

瀏覽器輸入地址加端口魏颓,打開springbootadmin后臺忘瓦,此時,沒有項目押袍,(圖為完成后截圖)


客戶端配置 springbootadmin 配置?

<dependency>

? ? <groupId>de.codecentric</groupId>

? ? <artifactId>spring-boot-admin-starter-client</artifactId>

? ? <version>2.0.0</version>

</dependency>

springcloud nacos 相關配置入上?

參數(shù)配置:

寫在非bootstrap.properties 配置文件中 :management.endpoints.web.exposure.include=*

nacos寫在bootstrap.properties 配置文件中(同上ip)

spring.application.name=client

spring.cloud.nacos.discovery.server-addr=192.168.1.31:8848

spring.cloud.nacos.config.server-addr=192.168.1.31:8848

加入nacos注解即可诵冒,無需springbootadmin相關注解

@EnableDiscoveryClient

@SpringBootApplication

public class DemoApplication {

? ? public static void main(String[] args) {

? ? ? ? SpringApplication.run(DemoApplication.class, args);

? ? }

}


啟動服務,在nacos后臺發(fā)現(xiàn)項目谊惭,

再次打開springbootadmin后臺汽馋,



代碼下載站地址:https://download.csdn.net/download/jialiuyang/11069675

————————————————

版權聲明:本文為CSDN博主「jly_靈寶娃」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權協(xié)議圈盔,轉載請附上原文出處鏈接及本聲明豹芯。

原文鏈接:https://blog.csdn.net/jialiuyang/article/details/88871225

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市驱敲,隨后出現(xiàn)的幾起案子告组,更是在濱河造成了極大的恐慌,老刑警劉巖癌佩,帶你破解...
    沈念sama閱讀 221,198評論 6 514
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件木缝,死亡現(xiàn)場離奇詭異,居然都是意外死亡围辙,警方通過查閱死者的電腦和手機我碟,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,334評論 3 398
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來姚建,“玉大人矫俺,你說我怎么就攤上這事〉г” “怎么了厘托?”我有些...
    開封第一講書人閱讀 167,643評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長稿湿。 經(jīng)常有香客問我铅匹,道長,這世上最難降的妖魔是什么饺藤? 我笑而不...
    開封第一講書人閱讀 59,495評論 1 296
  • 正文 為了忘掉前任包斑,我火速辦了婚禮流礁,結果婚禮上,老公的妹妹穿的比我還像新娘罗丰。我一直安慰自己神帅,他們只是感情好,可當我...
    茶點故事閱讀 68,502評論 6 397
  • 文/花漫 我一把揭開白布萌抵。 她就那樣靜靜地躺著找御,像睡著了一般。 火紅的嫁衣襯著肌膚如雪绍填。 梳的紋絲不亂的頭發(fā)上霎桅,一...
    開封第一講書人閱讀 52,156評論 1 308
  • 那天,我揣著相機與錄音沐兰,去河邊找鬼哆档。 笑死蔽挠,一個胖子當著我的面吹牛住闯,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播澳淑,決...
    沈念sama閱讀 40,743評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼比原,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了杠巡?” 一聲冷哼從身側響起量窘,我...
    開封第一講書人閱讀 39,659評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎氢拥,沒想到半個月后蚌铜,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,200評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡嫩海,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,282評論 3 340
  • 正文 我和宋清朗相戀三年冬殃,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片叁怪。...
    茶點故事閱讀 40,424評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡审葬,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出奕谭,到底是詐尸還是另有隱情涣觉,我是刑警寧澤,帶...
    沈念sama閱讀 36,107評論 5 349
  • 正文 年R本政府宣布血柳,位于F島的核電站官册,受9級特大地震影響,放射性物質發(fā)生泄漏难捌。R本人自食惡果不足惜攀隔,卻給世界環(huán)境...
    茶點故事閱讀 41,789評論 3 333
  • 文/蒙蒙 一皂贩、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧昆汹,春花似錦明刷、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,264評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至映皆,卻和暖如春挤聘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背捅彻。 一陣腳步聲響...
    開封第一講書人閱讀 33,390評論 1 271
  • 我被黑心中介騙來泰國打工组去, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人步淹。 一個月前我還...
    沈念sama閱讀 48,798評論 3 376
  • 正文 我出身青樓从隆,卻偏偏與公主長得像,于是被迫代替她去往敵國和親缭裆。 傳聞我的和親對象是個殘疾皇子键闺,可洞房花燭夜當晚...
    茶點故事閱讀 45,435評論 2 359