美文网首页
Spring Boot Admin -nacos备份

Spring Boot Admin -nacos备份

作者: zero_93a5 | 来源:发表于2020-06-17 13:18 被阅读0次

服务端:

 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发现服务

浏览器输入地址加端口,打开springbootadmin后台,此时,没有项目,(图为完成后截图)

客户端配置 springbootadmin 配置 

<dependency>

    <groupId>de.codecentric</groupId>

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

    <version>2.0.0</version>

</dependency>

springcloud nacos 相关配置入上 

参数配置:

写在非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后台发现项目,

再次打开springbootadmin后台,

代码下载站地址:https://download.csdn.net/download/jialiuyang/11069675

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

版权声明:本文为CSDN博主「jly_灵宝娃」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

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

相关文章

网友评论

      本文标题:Spring Boot Admin -nacos备份

      本文链接:https://www.haomeiwen.com/subject/cokzohtx.html