搭建eureka,gateway,admin,redis,docker系列一admin
Posted chenmengmeng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搭建eureka,gateway,admin,redis,docker系列一admin相关的知识,希望对你有一定的参考价值。
spring cloud admin
简介
Spring Boot Admin 用于监控基于 Spring Boot 的应用,它是在 Spring Boot Actuator 的基础上提供简洁的可视化 WEB UI。Spring Boot Admin 提供了很多功能,如显示 name、id 和 version,显示在线状态,Loggers 的日志级别管理,Threads 线程管理,Environment 管理等。
创建一个空的module项目
添加pom依赖
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> <version>2.1.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <version>2.1.2.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.jolokia/jolokia-core --> <dependency> <groupId>org.jolokia</groupId> <artifactId>jolokia-core</artifactId> <version>1.6.2</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
创建一个启动类
@EnableAdminServer @EnableEurekaClient public class dxtAdminApplication { public static void main(String[] args) { SpringApplication.run(dxtAdminApplication.class, args); } }
配置文件
spring: application: name: spring-boot-admin profiles: active: - secure server: port: 8788 # tag::configuration-eureka[] eureka: #<1> instance: leaseRenewalIntervalInSeconds: 10 health-check-url-path: /actuator/health client: registryFetchIntervalSeconds: 5 serviceUrl: defaultZone: ${EUREKA_SERVICE_URL:http://127.0.0.1:8761}/eureka/ management: endpoints: web: exposure: include: "*" #<2> endpoint: health: show-details: ALWAYS # end::configuration-eureka[] --- spring: profiles: insecure --- spring: profiles: secure security: user: name: "登录用户名" password: "登录密码" eureka: instance: metadata-map: user.name: "用户名" #These two are needed so that the server user.password: "密码" #can access the protected client endpoints
向注册中心注册自己
打开本地localhost:8788 就能看到admin了,我这里有2个api项目 一个gateway 一个admin
下一章就开始做Redisapi项目
以上是关于搭建eureka,gateway,admin,redis,docker系列一admin的主要内容,如果未能解决你的问题,请参考以下文章
Java之 Spring Cloud 微服务搭建网关SpringCloud Gateway微服务网关GateWay(第三个阶段)SpringBoot项目实现商品服务器端是调用
api-gateway实践(15)新服务网关 -运行环境搭建
SpringCloud基本微服务构建(Eureka+GateWay)
Spring Cloud Gateway 整合Eureka路由转发