这篇文章给大家介绍怎么在Spring boot Admin中使用eureka监控服务,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
环境介绍
IDE:intellij idea
jdk: java8
maven:3.3.9
spring boot:1.5.6
spring cloud:Edgware.BUILD-SNAPSHOT
搭建过程
1.对于之前的eureka-client服务我们不需要进行任何更改,保持原来的状态就行。
2.搭建spring boot admin服务(也是一个eureka服务)
3.测试结果
spring boot admin模块
这里一定要注意,到目前为止(2017年10月31日10点16分),我们不能对spring boot admin 使用Edgware.BUILD-SNAPSHOT版本的eureka,会报错,因为目前最新版的codecentric1.5.4版本不兼容的问题.
所以这里要对admin依赖的spring cloud版本降级,我使用的是Dalton.SR4版本。没有问题!
pom文件
<dependencies>
<!--admin的服务-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.5.4</version>
</dependency>
<!--admin的ui依赖-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
application
@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableAdminServer
public class AdminServerApplication {
public static void main(String[] args) {
SpringApplication.run(AdminServerApplication.class, args);
}
}
@EnableAdminServer 用来标记为admin应用的
其他的注解都和普通的eureka client 应用一致
yml文件
spring:
application:
name: admin-server
boot:
admin:
routes:
endpoints: env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,hystrix.stream
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
#测试,不使用密码
management.security.enabled: false
server:
port: 8089
结果展示
到此配置结束,我们依次启动eureka server,admin server,eureka client``eureka client2的应用
1.首先去eureka注册中心 http://localhost:8761/查看是否将所有的应用都已经注册
我们的admin-server也是作为一个服务被注册进来,这样才能发挥eureka的服务发现功能
2.查看admin server中的监控ui http://localhost:8089
关于怎么在Spring boot Admin中使用eureka监控服务就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。